Question: After the following code is executed, what are the values of c and d? Why? PiggyBank p = new piggyBank(); PiggyBank q = p; p.addNickels
After the following code is executed, what are the values of c and d? Why? PiggyBank p = new piggyBank(); PiggyBank q = p; p.addNickels (5); q.addNickels (3); double c = getTotal(); double d = q getTotal (); a. c = 5 d = 3 b. c = 0.25 d = 0.15 c. c = 0.25 d = 0.25 d. c = 0.15 d = 0.15 e. = 0.4 d = 0.4 Consider the following code segment. int numberOfCoins = 5; double taxRate = 4; double number = 3.0 Piggy Bank myMoney=new PiggyBank(); taxRate = numberOfCoins; numberOfCoins = number; Which of the following statements is true? a. A compile-time error occurs in line 2 because 4 is an int and not a double. b. A compile time error occurs in line 4 because an object is not being created with new. c. An error occurs in line 6 because numberofCoins and taxRate are not compatible types. d. An error occurs in line 7 because a double cannot be assigned to an int. e. The program will compile without errors. Consider the following code segment. Why? int sum = 200; int n = 0; if (n! = 0)&& (sum>90)) else return sum; What is the result when this code is executed? A run-time error occurs when evaluating sum. A compile-time error occurs when evaluating sum. 0 is returned. 200 is returned. 400 is returned
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
