O'Reilly logo

Programming with Java by Sunil Patekar, Mahesh Bhave

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required