Using inheritance to print car instance

Report a typo

Given a scenario where there is a superclass named Vehicle which has a constructor and a getter method, and a subclass named Car. You need to utilize inheritance mechanism to execute the functionality of subclass Car. When you create an instance of Car, the system should print 'Car'. Fill the blanks in the provided Java code to achieve this.

Fill in the gaps with the relevant elements
 class Vehicle {
     String type;
    public Vehicle (String type) {
        this.type = type;
    }
    public String getType() {
        return type;
    }
}

public class Car  Vehicle {
    public Car(){
        ("Car");
    }
}
public class Main {
    public static void main(String[] args) {
        Car myCar = new Car();
        System.out.println(myCar.getType());
    }
}
superextendspublicprivate
___

Create a free account to access the full topic