Question

The following Java code attempts to define an abstract class and use it. Identify the best way to correct the error to allow instantiation of a concrete class. abstract class Vehicle {     abstract void start();     void stop() {         System.out.println("Vehicle stopped.");     } } class Car extends Vehicle {     // Missing implementation } public class Main {     public static void main(String[] args) {         Car myCar = new Car();         myCar.start();     } }

A Add `void start() { System.out.println("Car started."); }` to the `Car` class.
B Remove the `abstract` keyword from the `start()` method in `Vehicle`.
C Change `Vehicle` to an interface.
D Make `Car` an abstract class as well.
E Remove the `start()` method from `Vehicle`.
Practice Next

Hey! Ask a query