0%
0 / 10 answered

Calling Class Methods Practice Test

10 Questions
Question
1 / 10
Q1

Consider the following class for a car rental service. The CarRental class stores how many cars are available. It has methods rentCar(int n) to reduce availability if enough cars exist and returnCar(int n) to increase availability. It also has getAvailable() that returns the current number available. A program instantiates CarRental cr = new CarRental(5); then calls cr.rentCar(2). The expected output of getAvailable() reflects the new availability. If getAvailable() is called next, what is the expected result?

Question Navigator