Acquiring the properties of a class into another class by extending the super class is known as inheritance.
extends
Extends is the keyword used here.
Real time example:
Vehicle can be assumed as a super class having the basic functionalities of a ordinary vehicle. Car, Bike can be subclasses of the Vehicle class having the common functions and properties defined in the Vehicle super class.
Note:
1. Private members of the superclass cannot be inherited by the subclasses.
2. Members having the default access specifier cannot be inherited by subclasses in other packages, as these members can only be accessible by there simple names in subclasses within the same package.
3. Constructors cannot be inherited by the subclasses.
4. A subclass can extend only one superclass.
Extends is the keyword used here.
Real time example:
Vehicle can be assumed as a super class having the basic functionalities of a ordinary vehicle. Car, Bike can be subclasses of the Vehicle class having the common functions and properties defined in the Vehicle super class.
Note:
1. Private members of the superclass cannot be inherited by the subclasses.
2. Members having the default access specifier cannot be inherited by subclasses in other packages, as these members can only be accessible by there simple names in subclasses within the same package.
3. Constructors cannot be inherited by the subclasses.
4. A subclass can extend only one superclass.
1 comment:
Good one:)
Keep it up!!!
Post a Comment