Answers for "The Bike superclass does not have a constructor."

0

java child class constructor with parents attributes

public class Car {

    private String name;
    private String manufacturerName;

    public Car(String name, String man) {
        this.name = name;
        this.manufacturerName = man;
    }
    // Getter method
    public String getName() {
        return name;
    }
    // Getter method
    public String getManufacturerName() {
        return manufacturerName;
    }
}

public class ElectricCar extends Car {

    public ElectricCar(String name, String man) {
        super(name, man);
    }

    public void charge() {
     System.out.println("Charging ...");
    }
}

ElectricCar modelS = new ElectricCar("Model S","Tesla");
// prints Tesla
System.out.println(modelS.getManufacturerName());
// prints Charging ...
modelS.charge();
Posted by: Guest on October-15-2020

Code answers related to "The Bike superclass does not have a constructor."

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language