CHAPTER 12
INHERITANCE
Let us imagine that a particular class is developed and used in some program. Now, another class is needed which is similar to this class but with more functionality (power). Does the time consumed in developing this class go waste? No, the Inheritance principle allows us to define a new class based on the previously designed class. We are required only to write a code related to additional functionality. The previously developed class is directly used. In technical jargon, the new class inherits the properties of old class.
12.1 Inheritance Basics
Consider a case where you want to develop class Time12
. Assume that you have class Time24
. Name Time24
stands for twenty-four hours clock. The hours can take values between 0 ...
Get Programming with Java now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.