Menu
Topics Index
...
`

Inheritance

Inheritance is specific to object-oriented programming, where a new class is created from an existing class. Inheritance (often referred to as subclasses) comes from the fact that the subclass (the newly created class) contains the attributes and methods of the parent class. The main advantage of inheritance is the ability to define new attributes and new methods for the subclass which are then applied to the inherited attributes and methods.

A class that is used as the basis for inheritance is called a superclass or base class. A class that inherits from a superclass is called a subclass or derived class. The terms parent class and child class are also acceptable terms to use respectively. A child inherits visible properties and methods from its parent while adding additional properties and methods of its own.


In this section, we'll discuss more about::

9.1 Java Class Inheritance
  • Inheritance, is one of three object oriented concepts, which helps to separate out common data and behavior (or member variables and methods) from multiple related ...Read More

9.2 Is-A Relationship In Java
  • The Java Class Inheritance supports the 'is-a relation'. Every sub-class object is also a super-class object, but every super-class object need not be a sub-class object. e.g., Every ...Read More

9.3 Passing Sub Class Object As Super Class Reference
  • We can use the objects sub-class type, where ever we have super-class type. This program shows how to create a method to compare the entertainments. The Entertainments...Read More

9.4 Assigning Sub Class Object To Super Class Reference In Java
  • Since every sub-class object is also a super-class object, we can assign a sub-class object to a super-class reference. This is also called as downcasting. e.g., the object of ...Read More

9.5 Assigning Super Class Reference To A Sub Class Reference In Java
  • Every sub-class object is also of type super-class. Although all of the super-class objects are not of the sub-class type, some of them are. So the super-class references can be ...Read More

9.6 Multilevel Inheritance In Java With Example Program
  • Java supports inheritance to provide a hierarchy for class definition and hence avoiding duplicate code and increasing maintainability. There is no limit on the levels of hierarchy. We...Read More

Dependent Topics : 8. Classes 

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App