Java Inheritance

description of image


Java Inheritance


Inheritance is one of the key features of object-oriented programming.

It allows us to derive new classes (subclasses) from an existing class
(superclass).

For example,

Class Animal {

// code of superclass

}
Class Dog extends Animal {
// code of subclass

}

Here, we derived the Dog class from the Animal class.
To derive a class, we use the extends keyword.
The class inherits all the features from the nimal class.
In addition to that, we can add dog specific features to the class



Quiz


Question Text