Java - Inheritance
You have two classes:
How can you modify the
class Vehicle {
String type = "Vehicle";
void printType() {
System.out.println(type);
}
}
class Car extends Vehicle {
String type = "Car";
void printType() {
System.out.println(type);
System.out.println(super.type);
}
}How can you modify the
Car class constructor to call the parent constructor and print "Vehicle created" before printing types?