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.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
What is the value of n3 after the following code is executed:
int n1 = 2;
int n2 = n1 + n1;
int n3 = n2;
n1 = n1 * 2;
n3 = n1 + 10;
A/
#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?
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
- What occurs when you multiply ptr by 4? Assuming that ptr is a reference to an int, what happens isarrow_forwardGiven: 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.arrow_forwardAnalyze 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_forward#include <stdlib.h> #include <time.h> #include <stdio.h> int main(void){ int money_start, bet, money_bet; int money_result; int randomNumber = 0; int n = 0; srand(time(0)); randomNumber = rand() % n; printf("Entering the casino, how much money do you have? "); scanf("%d", &money_start); printf("We are playing roulette, odd or even bets only.\nPlace your bet!"); printf("Enter 1 for odd, 2 for even, 0 to quit: "); scanf("%d", &bet); printf("How much money do you want to bet? "); scanf("%d", &money_bet); while (( bet == 1 || bet == 2 )) { if (( bet == 1)) { printf("You bet $%d on odd numbers.", money_bet); if ((randomNumber % 2 == 0)) { money_result = money_start - money_bet; printf("You lose!"); printf("Your balance is $%d!", money_result);} else { if ((randomNumber…arrow_forwardRewrite the following code segment using the conditional operators (?/:) if (x > y) Z = 1; else z = 20;arrow_forward
- What's wrong with this code? float q;int *p;q = 100.7;p = &q;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_forward
- In C++ Create an array of random 10 random numbers. Use the "range-based for loop" (sometimes called "enhanced for loop") to put the values into the array (users choice of number) and use the "range-based for loop" to output the numbers to the console.arrow_forwardInt cube ( int x){ // returns cube of x : return x.x.x. :)* O False Truearrow_forwardWrite a program in C++ code: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