|
Could a main() method create a Car object? A good answer might be:Sure, as long as it had access to the class definition. | |
Using a Car Object
To see if the design for the class Car is correct, let us use it in a program. Here is a short program that uses a Car object for calculating miles per gallon: The program creates an object of the class Car, and saves a reference to it in the variable car. | |
QUESTION 3:Fill in the blanks so that the program prints out the miles per gallon for a car with:
(Look at the previous page to see the constructor). Click Here after you have answered the question |