Calling parent class constructor in derived class

Report a typo

You are composing a simple Java program which includes two classes: Vehicle and Car. Car class is a derived class from the Vehicle class. You notice that when a Car object is created, it doesn't print out 'Vehicle constructor'. Fill the blanks in the code to make it so that the default constructor of the parent class is called when an object of the derived class is being created.

Fill in the gaps with the relevant elements
class  {
    Vehicle() {
        System.out.println("Vehicle constructor");
    }
}

class   Vehicle {
    Car() {
        ();
        System.out.println("Car constructor");
    }
  
    public static void main(String[] args) {
        new Car();
    }
}
superextendsVehicleCar
___

Create a free account to access the full topic