Object-oriented programming for Java - 2

Java Method Overriding


1. Method Overriding

In this method, use override, the display( ) function will be only call the new one, not first one.

 

2. Super Keyword in Java Overriding

Use super keyword can call the function in first class.

 

3. Access Specifier in Overriding

The same method declared in the superclass and its subclasses can have different access specifiers.

--> P.s. Only use those access specifiers in subclasses that provide larger access than the access specifier of the superclass.