Could a main() method create a Car object?

Answer:

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 try to use it in a program. Here is a short program that uses a Car object to calculate miles per gallon:

import Car ;  // assume that a class definition is available

class MilesPerGallon
{
  public static void main( String[] args )
  {
    Car car = new Car( , ,   );

    System.out.println( "Miles per gallon is " +  );
  }
}

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 parameters required by the constructor.)