Learn AP Comp Sci

Problem of the Day

Monday, February 9, 2026


Problem:

Which of the following represent appropriate descriptions for a class designed to model cars?

classinstanceaccessor methodmutator method
a.CarmyCarcheckGasAmountdrive
b.myCarCarcheckGasAmountdrive
c.CarmyCardrivecheckGasAmount
d.myCarCardrivecheckGasAmount

Show solution:

The correct answer is a. Class names are typically capitalized, while objects (instances) of a class are not capitalized. The checkGasAmount, based on the method name, is intended simply to access the amount of gas in the car, while the drive presumably will use up gas in the car, changing its state (a mutator).