• A class can be defined in terms an existing class.

• The new class gets all of the methods and state variables of the old classby default.

• The new class can add new methods and state variables.

• The new class can redefine methods and state variables of its parent.

• No multiple inheritance

•Interfaces provide the good features of multiple inheritance.

Superclass
A super class is basically the same as any other class in Java, except that we know thatwe want other classes to be created from it. Don’t worry about how that’s done yet; firstlet’s just see what a super class can look like.

But wait, that looks like just a normal class? That’s right. A superclass can look like anytypical class. So, the magic of the superclass does not lie within the superclass itself, butwithin the subclass. You can call Super class as a Parent class.
Subclass
A subclass is a child of the parent class. Essentially, subclasses come from theirsuperclasses. Subclass draws the characteristics from the parent class in other words .
An simple example of inheritance
The following class extends the definition of a Point to three dimensions.
class Point3D extends Point {

double z;
Point3D (double x, double y, double z) {

this.x = x;

this.y = y:

this.z = z;

}
public double length() {return Math.sqrt(x*x + y*y + z*z);}

}
• The x and y values of the point values come from Point automatically.

• The getX and setX methods from Point do not have to be rewritten.

• The length method needs to be redefined.

• The addPoints method can be retained, but an addPoints3D needs to beadded.
Inheritance and instantiation

• Inheritance and instantiation are unrelated.

• Class (object blue prints) have a strict hierarchy (no multipleinheritance).

• Objects can instantiate other objects irrespective of the class hierarchy.

• The instantiating object points to the instantiated object, but otherobjects may also point to the instantiated object so there is no stricthierarchy of objects.

• Objects become garbage when they are no longer pointed to.