Answer:

Easy. The filled in program is below.

Picture of Two Objects

two car objects

In this program, two defferent Car objects are constructed, each with different data, and the miles per gallon calculation is performed on each.


class Car
{
  . . . .
}

class MilesPerGallon
{
  public static void main( String[] args ) 
  {
    Car car1 = new Car( 32456, 32810, 10.6 );
    System.out.println( "Miles per gallon of car 1 is "  
        + car1.calculateMPG() );

    Car car2 = new Car( 100000, 100300, 10.6 );
    System.out.println( "Miles per gallon of car 2 is " 
        +  car2.calculateMPG() );

  }
}

The picture shows the situation just after the second object has been constructed. Two objects have been constructed according to the definition of Car. The definition of class MilesPerGallon contains the static main() method.

QUESTION 14:

There are two objects, but uses the same names for its instance variables! Is this a mistake?