Wednesday 28 August 2013

Inheritance

it is the one of the most important feature of object oriented language.
Inheritance means one class inherits the property of another class.
for inheritance we use "extends" keyword.

Example;-


in this we didn't declare variable i in class Y but we use it.we use it through inheritance.
we inherit variable i of X class through extends keyword and use in class Y.

in this class X is Base class or Super Class or Parent class
class Y is derived class or child class

Example 2:-



it inherit all methods of class X..


No comments :

Post a Comment