Replacement of the parent class constructor in Java
class Man {
public String name;
public Man(String name) {
this.name = name;
}
}
class Employee extends Man {
public String position;
public Employee(String name) {
super(name);
this.position = "unknown";
}
}
Employee employee = new Employee("Max");
//employee.position is "unknown"
- Log in to post comments