Methods
Not only does a subclass inherit the superclass's fields, it also inherits the superclass's methods. * The methods exist in the superclass, but the subclass can call them.
We can imagine our Employee extends Person class diagram looking like

The Employee class has all the Person fields and methods, but the fields and methods only exist in Person.
Practice Exercise¶
It is important to note that constructors are not inherited.
Drill¶
Inheritance/com.example.inheritance.drills.Employee
Employee'sgetInfo()method usesfirstNameandlastNamereferences to printEmployeeinformation.* Change this method to callpublic String getInfo() { return firstName + " " + lastName + " " + age + " " + title + " " + salary; }getName(), which is inherited fromPerson, instead of using thefirstNameandlastNamereferences. * RunEmployeeAppto make sure the change works. Now yourEmployeesubclass is calling an inherited superclass method.(Solution: Employee3.java, EmployeeApp2.java)
Reference: https://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html