Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 13.3, Problem 13.3.3CP
Program Plan Intro
Program:
//definition of class Test
public class Test
{
//declaration of main function
public static void main(String[] args)
{
/*declaration of the abstract class Number and assigning value as 3 */
Number x = 3;
/*Reference the intValue() function of integer type using object x and print the value */
System.out.println(x.intValue());
/*Reference the doubleValue() function of
double type using object x and print the value */
System.out.println(x.doubleValue());
}
}
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
In Java trace the table for the do while loop
public class Main { public static void main(String[] args) { int x,j,y; /// Question 1 j = 30; x=5; do { j=j-x-2; --x; }while (j > 20);
j
x
j>20
JAVA
Determine the output for the following code
public class Beta extends Baap
{
public int h = 44;
public int getH( )
{
System.out.println("Beta " + h);
return h;
}
public static void main(String[ ] args)
{
Baap b = new Beta();
System.out.println(b.h + " " + b.getH( ));
Beta bb = (Beta) b;
System.out.println(bb.h + " " + bb.getH( ));
}
}
public class Baap
{
public int h = 4;
public int getH( )
{
System.out.println("Baap " + h);
return h;
}
}
Java -
public static void test_b(int n)
{
if (n>0)
test_b(n-2);
System.out.println(n + " ");
}
What is printed by the call test_b(6)?
Chapter 13 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 13.2 - Prob. 13.2.1CPCh. 13.2 - The getArea() and getPerimeter() methods may be...Ch. 13.2 - True or false? a.An abstract class can be used...Ch. 13.3 - Prob. 13.3.1CPCh. 13.3 - Prob. 13.3.2CPCh. 13.3 - Prob. 13.3.3CPCh. 13.3 - What is wrong in the following code? (Note the...Ch. 13.3 - What is wrong in the following code? public class...Ch. 13.4 - Can you create a Calendar object using the...Ch. 13.4 - Prob. 13.4.2CP
Ch. 13.4 - How do you create a Calendar object for the...Ch. 13.4 - For a Calendar object c, how do you get its year,...Ch. 13.5 - Prob. 13.5.1CPCh. 13.5 - Prob. 13.5.2CPCh. 13.5 - Prob. 13.5.3CPCh. 13.5 - Prob. 13.5.4CPCh. 13.6 - Prob. 13.6.1CPCh. 13.6 - Prob. 13.6.2CPCh. 13.6 - Can the following code be compiled? Why? Integer...Ch. 13.6 - Prob. 13.6.4CPCh. 13.6 - What is wrong in the following code? public class...Ch. 13.6 - Prob. 13.6.6CPCh. 13.6 - Listing 13.5 has an error. If you add list.add...Ch. 13.7 - Can a class invoke the super.clone() when...Ch. 13.7 - Prob. 13.7.2CPCh. 13.7 - Show the output of the following code:...Ch. 13.7 - Prob. 13.7.4CPCh. 13.7 - What is wrong in the following code? public class...Ch. 13.7 - Show the output of the following code: public...Ch. 13.8 - Prob. 13.8.1CPCh. 13.8 - Prob. 13.8.2CPCh. 13.8 - Prob. 13.8.3CPCh. 13.9 - Show the output of the following code: Rational r1...Ch. 13.9 - Prob. 13.9.2CPCh. 13.9 - Prob. 13.9.3CPCh. 13.9 - Simplify the code in lines 8285 in Listing 13.13...Ch. 13.9 - Prob. 13.9.5CPCh. 13.9 - The preceding question shows a bug in the toString...Ch. 13.10 - Describe class-design guidelines.Ch. 13 - (Triangle class) Design a new Triangle class that...Ch. 13 - (Shuffle ArrayList) Write the following method...Ch. 13 - (Sort ArrayList) Write the following method that...Ch. 13 - (Display calendars) Rewrite the PrintCalendar...Ch. 13 - (Enable GeometricObject comparable) Modify the...Ch. 13 - Prob. 13.6PECh. 13 - (The Colorable interface) Design an interface...Ch. 13 - (Revise the MyStack class) Rewrite the MyStack...Ch. 13 - Prob. 13.9PECh. 13 - Prob. 13.10PECh. 13 - (The Octagon class) Write a class named Octagon...Ch. 13 - Prob. 13.12PECh. 13 - Prob. 13.13PECh. 13 - (Demonstrate the benefits of encapsulation)...Ch. 13 - Prob. 13.15PECh. 13 - (Math: The Complex class) A complex number is a...Ch. 13 - (Use the Rational class) Write a program that...Ch. 13 - (Convert decimals to fractious) Write a program...Ch. 13 - (Algebra: solve quadratic equations) Rewrite...Ch. 13 - (Algebra: vertex form equations) The equation of a...
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Getting a error message and I dont understand why public class DebugTwo2 { public static void main(String args[]) { { int a, b; a = 7; b = 4; System.out.println("The sum is " + (a + b); System.out.println("The difference is " + (a - b); System.out.println("The product is " + (a * b); }arrow_forwardCreate a flowchart for this Java program class Test {public static void main(String[] args) { for (int i = 1; i <= 10; ++i) { if (i == 5) { break;}System.out.println(i); } }}arrow_forwardCreate a Java program that shows Pass by value and pass by reference.arrow_forward
- Identify 2 errors in this code: public class Test { public static void main(String[] args) { nPrintln(5, "Welcome to Java!"); } public static void nPrintln(String message, int n) { for (int i = 0; i < n; i++) { System.out.println(message); } return n; }}arrow_forward3. What will be the output of the following Java Program? class Test { public static void main(String args[]) { int arr[] = new int[2]; System.out.println(arr[0]); System.out.println(arr[1]); }}arrow_forwardWrite a test class to test the methods length, charAt, substring, and indexOfin the java.lang.String class.arrow_forward
- Identify and fix the errors in the following code: 1 public class Test { 2 public static void main(String[] args) { 3 int i = k + 2; 4 System.out.println(i); 5 } 6 }arrow_forwardShow the output of the following programs. (Hint: Draw a table and list the variables in the columns to trace these programs.) (java language)(a)public class Test {public static void main(String[] args) {for (int i = 1; i < 5; i++) {int j = 0;while (j < i) {System.out.print(j + " ");j++;}}}} (b)public class Test {public static void main(String[] args) {int i = 0;while (i < 5) {for (int j = i; j > 1; j--)System.out.print(j + " ");System.out.println("****");i++;}}} (c)public class Test {public static void main(String[] args) {int i = 5;while (i >= 1) {int num = 1;for (int j = 1; j <= i; j++) {System.out.print(num + "xxx");num *= 2;} System.out.println();i--;}}} (d)public class Test {public static void main(String[] args) {int i = 1;do {int num = 1;for (int j = 1; j <= i; j++) {System.out.print(num + "G");num += 2;} System.out.println();i++;} while (i <= 5);}}arrow_forwardPROGRAM SIMULATION. Understand the given JAVA program and write the output. b. public class ChangeIt { public void doIt( int[] z ) { z[0] = 0; } } public class TestIt { public static void main ( String[] args ) { int[] myArray = {1, 2, 3, 4, 5} ; ChangeIt.doIt(myArray ); for (int j=0; j<myArray.length; j++ ) System.out.print( myArray[j] + " " ) ; } }arrow_forward
- Correct any mistake(s) in the following Java code and write your answer on the right (d) public static void main(String[] args){ printSalary( ); System.out.println(“Salary is ”+salary); } public static void printSalary( ) { double salary=20000; System.out.println(“Salary is ”+salary); } (e) public static void doubleNum(int num){ num=2*num; return num; }arrow_forwardI need this solved in java. The required testing inputs and their outputs are attached below. Here is the code default template: import java.util.Scanner; public class LabProgram { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int highwayNumber; int primaryNumber; highwayNumber = scnr.nextInt(); /* Type your code here. */ }}arrow_forwardWrite the unit tests class for the given Java program: public static void main(String[] args) { String computerMove; switch ((int) (3 * Math.random())) { case 0: computerMove = "Rock"; break; case 1: computerMove = "Paper"; break; default: computerMove = "Scissors"; break; } System.out.println("The computer's move is " + computerMove); }arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education