Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition)
11th Edition
ISBN: 9780134671710
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 13.3, Problem 13.3.1CP
Program Plan Intro
Given Code:
//declaration of class
public abstract class ex1
{
//declaration of main method
public static void main(String[] args)
{
/*declaration of a number reference of "Number" type as an instance ofinteger*/
Number numberRef = new Integer(0);
/*type casting the "numberRef" into creation of a double type object*/
Double doubleRef = (Double)numberRef;
}
}
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
#include main() {int=a, b=2, x=0, x=a + b * a + 10/2 * a, printf("value is =%d", x);}
What is the value?
#include <stdio.h>
int main(){printf(" enter two integers and ill add them \n");
int integer1;int integer2;
scanf("%d,%d",&integer1, &integer2);
int sum;sum = integer1+integer2;
printf("sum is %d\n", sum);
return 0;
}
when i run this code the sum is incorrect like when i type in 44 55 it says the sum is 109. whats wrong with the code?
Given: an int variable num,
an int array current that has been declared and initialized,
an int variable aNum that contains the number of elements in the array,
an int variable bNum that has been initialized,
and a bool variable isNum,
Write code that assigns TRUE to isNum if the value of bNum can be found in current, and that assigns FALSE
to isNum otherwise.
Use only num, current, aNum, bNum, and isNum.
Chapter 13 Solutions
Introduction to Java Programming and Data Structures: Brief Version (11th Global 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
- Analyze the following code: int x = 0;int y = ((x < 100) && (x > 0)) ? 1: -1; The code has syntax error. y becomes 1 after the code is executed. y becomes -1 after the code is executed. The code has run time error.arrow_forward#include <stdio.h> int main(){ int arr[10]; int i; for (i=0; i<10; i++){ arr[i] = i; } for (i=0; i<10; i++){ printf("arr[%d] = %d\n", i, arr[i]); } return 0;} Copy the code and modify it as follows: Add another separate array of 10 integers. The following code parts are to be added (in the same order as specified) after the printing of the values of the first array:(1) Copy the content of the first array to the second array. Add 10 to each of the values of the second array. Make use of a single loop to achieve this part.(2) Print each element of the second array. Make use of another loop for this partarrow_forwardplease solve the question new solution, don't copy other solutions in questions bank c++ In this task, you are required to write a code that converts an Octal number into its equivalent Decimal value or vice versa. The user first selects the conversion choice by inserting 1 or 2. Choice 1 is followed by inserting an Octal integer and getting its Decimal equivalent value as an output. Choice 2 requires inserting a Decimal integer and prints out its Octal equivalent. The Octal numeral system, is the base-8 number system, and uses the digits 0 to 7, that is to say 10 octal represents 8 Decimal and 100 octal represents 64 Decimal. Convertion from an Octal integer into Decimal In the Decimal system, each number is the digit multiplied by 10 to the power of its location (starting from 0). For example: 74 decimal = 7 x 10^1 + 4 x 10^0 1252 decimal = 1 x 10^3 + 2 x 10^2 + 5 x 10^1 + 2 x 10^0 each number is the digit multiplied by 8 to the power of its location (starting from 0).…arrow_forward
- #include <stdio.h> struct Single { int num; }; void printSingle(int f) { int binaryNum[33]; int i = 0; while(f>0) { binaryNum[i] = f % 2; f = f/2; i++; } for (int j=i-1; j>= 0; j--) { printf("%d",binaryNum[j]); } } int main() { struct Single single; single.num = 33; printf("Number: %d\n",single.num); printSingle(single.num); return 0; }arrow_forward#includecstdio.h> int x=10; void func1() 7 printf("x=%d\n", x); return; 8 10 int func2(int a, int b) 15 return a+b; 16 18 19 ... func3(...) 20 21 .. return ... int main() 27 { int x-1, y=2; func1(); 28 29 30 int z=func2(x, y); printf("z-%d\n", z); 31 34 Figure 2. C Program for Q2 What is the output after execution of line 29 and 32? a. b. func3() in line 19 to 23 is incomplete. Write the function, func30 to compute and print the volume of cuboid with length x, width y and height z. c. Complete line 33 to call func3() that you created in part (b).arrow_forwardWhat is the output of this code? def func(a,b): if(b==1): return a else: return a* func(a,b-1) A It adds a and b (B) None of these choices © It multiplies a and b (D) It raises a to the power of barrow_forward
- 4. Complete the following Java code that generates a random integer in the range between 4 and 12, inclusive : Random rand = new Random();arrow_forwardLanguage: Python Write a function named factorial(x) that computes the factorial of a number. Include a docstring. Make sure you throw an error (such as ValueError) if x is negative or not an integer. You must implement this yourself (you can't use math.factorial). You can use the following procedure for the factorial: Set the result to 1 Loop over the values 1 to x, multiplying the result each time Return the result Here (as in later problems), I'll put ... where you should write code. Fill in the following: -> # write a function that calculates the factorial of an integer def factorial(x):... # !Check for input is integer or not, must be integer # print something that says integer or not # do calculations and return final result (several lines) result = 1 # use for-loop to calculate the factorial given x and return result ... # your input (you may use input command to ask user input) x = 10 factorial(x)arrow_forwardGiven the following code, what is the value of *p? int i;int *p;i = 5;p = &i;arrow_forward
- #include <stdio.h>void cubeByReference( int *nPtr ); // function prototypeint main( void ){ int number = 5; // initialize number printf("The original value of number is %d", number ); // pass address of number to cubeByReference cubeByReference( &number ); printf("\nThe new value of number is %d\n", number );} // end main void cubeByReference( int *nPtr ){ *nPtr = *nPtr* *nPtr* *nPtr;} passing argument by reference - We modify the code above 1- define a second argument (example "int number2 = 9") and a pointer to it 2- define a second function (addByReference) that adds number2 to number - passing both arguments by reference 3- print-out the result (that is in number) Upload the output and .c codearrow_forward// Add to this partially built code // fill in code where there is a TODO #include using namespace std; change (a float) // TODO: calculate the int main() cout.setf(ios:fixed): cout.setf(ios:showpoint); // show decimals even if not needed cout.precision(2); // two places to the right of the decimal // TODO: enter the missing types below int time; float ticketPrice; destination; //'c'=Chicago, 'P'=Portland, 'M'=Miami typeOfDay; //'D'=weekDay 'E'=weekEnd // TODO: If the user's payment is too little, then print this message: cout > destination; cout > time; cout > typeOfDay; // TODO: set isWeekend to true if typeOfDay is 'E', otherwise false // otherwise print these 2 lines: // Depending upon the destination, and whether it is weekend, day/night // set the appropriate price //I recommend using a switch // I am providing much of the Input and Output dialog to simplify this program cout > num Tickets; // TODO: calculate the totalCost based on the number of tickets and ticketPrice, then…arrow_forward5- What is the output for y? int y = 0; for (int i = 0; i< 10; ++i) { y +=i; } cout << y;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