Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

After the following code is executed, what are the values of c and d? Why? PiggyBank p = new piggyBank(); PiggyBank q = p; p.addNickels

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Microsoft SQL Server 2012 Programming

Authors: Paul Atkinson, Robert Vieira

1st Edition

1118102282, 9781118102282

More Books

Students also viewed these Databases questions