1public class Car {
2
3 private String name;
4 private String manufacturerName;
5
6 public Car(String name, String man) {
7 this.name = name;
8 this.manufacturerName = man;
9 }
10 // Getter method
11 public String getName() {
12 return name;
13 }
14 // Getter method
15 public String getManufacturerName() {
16 return manufacturerName;
17 }
18}
19
20public class ElectricCar extends Car {
21
22 public ElectricCar(String name, String man) {
23 super(name, man);
24 }
25
26 public void charge() {
27 System.out.println("Charging ...");
28 }
29}
30
31ElectricCar modelS = new ElectricCar("Model S","Tesla");
32// prints Tesla
33System.out.println(modelS.getManufacturerName());
34// prints Charging ...
35modelS.charge();
36