Sunday, June 17, 2012

What is Inheritance?

Inheritance is a relationship among classes, wherein one class shares the structure or behaviour defined in another class


Inheritance is the property which allows a Child class to inherit some properties from its parent class.
In Java this is achieved by using extends keyword.
Only properties with access modifier public and protected can be accessed in child class.

The two most common reasons to use inheritance are:
To promote code reuse
To use polymorphism

No comments:

Post a Comment