Complete the code to declare a class named Car.
public class [1] { // class body }
The class name should start with a capital letter and match the intended name. Here, Car is correct.
Complete the code to create an object of class Car.
Car myCar = new [1]();To create an object, use the class name exactly as declared. Here, Car is correct.
Fix the error in the code to properly override the method start in class Car.
public class Car { public void start() { System.out.println("Car started"); } } public class SportsCar extends Car { @Override public void [1]() { System.out.println("SportsCar started fast"); } }
Method names are case-sensitive. To override, use the exact method name start.
Fill both blanks to define a class that inherits from Vehicle and overrides the move method.
public class Car [1] Vehicle { @Override public void [2]() { System.out.println("Car is moving"); } }
implements instead of extendsUse extends to inherit from a class and override the move method.
Fill all three blanks to create a simple interface and a class that implements it.
public interface [1] { void [2](); } public class Car implements [3] { public void start() { System.out.println("Car started"); } }
The interface is named Engine, it declares the method start, and the class Car implements Engine.