A class that is derived from another class is called a subclass (also a derived class, extended class, or child class). The class from which the subclass is derived is called a superclass (also a base class or a parent class). Excepting Object, which has no superclass, every class has one and only one direct superclass (single inheritance). In the ...

Read More

Below are Various types of inheritance in Java. We will see each one of them one by one. 1) Single Inheritance : Single inheritance is easy to understand. When a class extends another one class only then we  call it a single inheritance. The below flow diagram shows that class B extends only one class which is A. Here A is a parent class of B and B...

Read More

Declaring a method in subclass which is already present in parent class is known as method overriding. The following is an example of method overriding : abstract class Mammal { protected abstract String move(); } class Human extends Mammal { @Override protected String move() { return "I walk to move !!"; } } class Whale ex...

Read More

The ‘is a’ relationship is expressed with inheritance and ‘has a’ relationship is expressed with composition. Both inheritance and composition allow you to place sub-objects inside your new class. Two of the main techniques for code reuse are class inheritance and object composition.   Inheritance is uni-directional. For example House is a Building...

Read More

Polymorphism – means the ability of a single variable of a given type to be used to reference objects of different types, and automatically call the method that is specific to the type of object the variable references. In a nutshell, polymorphism is a bottom-up method call. The benefit of polymorphism is that it is very easy to add new classes of ...

Read More

FOLLOW US ON LinkedIn



Explore Tutu'rself