single inheritance program in java
Answers
Answered by
0
Answer:
Inheritance Example In this example, we have a base class Teacher and a sub class Physics Teacher. Since class Physics Teacher extends the designation and college properties and work() method from base class, we need not to declare these properties and method in sub class. Here we have collegeName, designation and work() method which are common to all the teachers so we have declared them in the base class, this way the child classes like MathTeacher, Music Teacher and PhysicsTeacher do not need to write this code and can be used directly from base class.
Similar questions