Inheritance (IS-A Relation) - Tecnew

Home Ads

Inheritance (IS-A Relation)

Inheritance (IS-A Relation)

Share This
Inheritance is a mechanism in which one object aquarius all the properties and behaviour of parent class to child class.

Advantages: code reusability and extensibility

While heritance all the members of a class me will be inherited in to subclass except private members and constructors.

Types of inheritance:

There are 4 types of inheritance is given below

1. Single inheritance.
2. Multiple inheritance.
3. Multilevel inheritance.
4. Hierarchial inheritance.

Multiple inheritance is not supported java.

Calling to a super class methods or variables it is possible only by a word "super".

Advantages:
  1. Reduce code redundancy
  2. Provides code reusability
  3. Reduces source code sizes and improves code reusability
  4. Code is easy to manage divided into parent and child class
  5. Supports Code exntendability by overriding the base class functionality with in child class
Disadvantages:

  1. In Inheritance base class and child class are tightly coupled.Hence if you change the code of parent class it will get affected to the all the child classes.
  2. In class hierarchy many data numbers remain unused andathe memory allocated to them is not utilised. Hense effect performance of your program if you have not implemented inheritance correctly.

No comments:

Post a Comment