This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
There are two classes: an abstract Person and Employee class. The Employee class extends Person class. The Person class has two methods: getName() and setName(String) The Employee class has two Methods: getEmpID() and setEmpID(int)
As per the above code, the "username" reference is of type Person and refer to an Employee object.
so using the "username" reference, we can call only the methods from Person class because while compiling, JAVA looks at the reference type.
But in the above code, I have called the classes from the Employee class using the Person reference and it works. see the following code