Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In the Toy class below, the raisePrice method is intended to increase the value of the instance variable price by the value of the

  

In the Toy class below, the raisePrice method is intended to increase the value of the instance variable price by the value of the parameter surcharge. The method does not w i work as intended. public elass Toy private String name: private double prices public Toy (String n, double p) name n: price - pa public void raisePrice (double surcharge) // Line 12 return price+ surcharge; // Line 14 Which of the following changes should be made so that the class definition compiles without error and the method raisePrice works as intended? Replace line 14 with surcharge + price. O Replace line 14 with price += surcharge;. Replace line 14 with return price + surchargez. Replace line 12 with public raisePrice (double surcharge). E Replace line 12 with public double raisePrice (double surcharge).

Step by Step Solution

3.48 Rating (148 Votes )

There are 3 Steps involved in it

Step: 1

Answer The correct option is B Replace ... 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

Marketing

Authors: Dhruv Grewal

3rd Canadian edition

1259105040, 1259105043, 1259030659, 1259030652, 978-1259030659

More Books

Students also viewed these Accounting questions