0%
0 / 15 answered

Object Creation and Storage (Instantiation) Practice Test

15 Questions
Question
1 / 15
Q1

Consider the following class; what method would you call to achieve starting the engine?


public class Car {

    private String make;

    private String model;

    // Constructor creates a Car object with identifying information.

    public Car(String make, String model) {

        this.make = make;

        this.model = model;

    }

    // startEngine prints a message using stored fields.

    public void startEngine() {

        System.out.println("Engine started: " + make + " " + model);

    }

    public static void main(String[] args) {

        Car myCar = new Car("Ford", "Focus");

        // The object is used via its reference.

    }

}

Question Navigator