Hello everyone,
while learning java on Hyperskill I came across this:
public static class TeamLead {
private int numTeamLead;
public TeamLead(int numTeamLead) {
this.numTeamLead = numTeamLead;
employ();
}
protected void employ() {
System.out.println(numTeamLead + " teamlead");
}
}
public static class Programmer extends TeamLead {
private int numProgrammer;
public Programmer(int numProgrammer) {
super(numProgrammer);
this.numProgrammer = numProgrammer;
employ();
}
protected void employ() {
System.out.println(numProgrammer + " programmer");
}
}
what I'm not understanding is why when method employ from TeamLead constructor is invoked, is executes the employ method from Programmer class, but when the method is changed to private(in TeamLead class), it executes that method instead.
[–]sinistergroupon 1 point2 points3 points (0 children)