ProAnswers.org

What is Inheritance?

Inheritance is a mechanism in which one object acquires all the properties and behaviour of another object of another class. It represents IS-A relationship. It is used for Code Resusability and Method Overriding.

• Inheritance is the process by which objects of one class acquire the properties of objects of another class.

• A class that is inherited is called a superclass.

• The class that does the inheriting is called a subclass.

• Inheritance is done by using the keyword extends.

The two most common reasons to use inheritance are:

o To promote code reuse

o To use polymorphism