I have a basic inheritance situation with an overloaded method in the super class.
public class Person {
private String name;
private int dob;
priva
The overload resolution happens during compile time, not at runtime.
So, when you call getWorkDetails(this)
, this
is assumed to be a Person
(which is the static type) and hence called the corresponding overload.
Note: Using this
inside Employee
class would have made it an Employee
type. You can verify this by overloading work()
in Employee
like this.
class Employee extends Person {
...
public void work() {
getWorkDetails(this); // This should print "This person is an Employee"
}
}