Inheritance in Java

Inheritance is one of the fundamental concepts of Object Oriented Programming paradigm. As the name suggest, in inheritance, we make new classes by inheriting functionality from already defined classes. As you know, a class can contains attributes and methods, so inheritance facilitate developers to include already defined attributes or methods in new classes without copying the code from existing classes.

Soon I would explain this concept with the help of code sample. Lets first see, what are the main benefits of inheritance.

Benefits of Inheritance

There are 2 fundamental benefits of inheritance: 
  1. It provides Code Re-usability, hence less time to develop new components. As we make new software components (also called classes) by extending existing classes.
  2. It improves the quality of new components. After the software is developed, one of the most important task is Testing it as per requirements. It requires resources who test the developed software components. When we create new components by inheriting some functionality from existing components, we only need to test the newly added functionality, as inherited functionality is already well tested. So its mean less time to deliver new functionality and less testing, hence you can put more concentration and resources on new functionality, so it helps to improve quality of new components.

Inheritance is very important topic in OOP. So I have divided into multiple sections:
  1. How Inheritance Works in Java - Basic Sample Code

  2. Inheritance without Compromising Encapsulation

  3. Role of Access Modifiers in Java Inheritance

  4. Using Protected Access Modifier Correctly

  5. Method Overriding in Java

 

 

 

 



Comments

  1. THANKS SIR, YOUR ARTICLES IS HELPING STUDENTS WITCH MISSED LECTURES UNFORTUNETALY.....LIKE ME...

    ReplyDelete

Post a Comment