Java – Method overriding

PREV     NEXT

If a method inherited from the superclass requires a different definition other than the definition provided in the superclass, then the method can be redefined or overridden. The process of redefining/overriding the method is called as Method overriding.

The overridden method must have the same signature as that of the parent class method. Two methods are considered having same signature when their return type , method name, count and type of arguments are same.

Example:


COMPILE & RUN

Output:

Parrot is flying

The overridden method must have the same signature as that of the parent class method.

PREV     NEXT

Share this website !!!
Facebook Twitter Linkedin