Category Java

Method Hiding in Java

Method hiding in Java

A static method (class method) cannot be overridden in Java. But if a static method defined in the parent class is redefined in a child class, the child class’s method hides the method defined in the parent class. This mechanism…

Exception Handling with Method Overriding in Java

Rules of Exception Handling with Java Method Overriding

In this tutorial, we will understand about rules for exception handling, while overriding method in Java with the help of various example programs. When a superclass method (overridden method) declares that it can throw an exception, then the subclass method…

Covariant Return Types in Java with Example

Covariant return type in Java

In this tutorial, we will understand covariant return types in Java with the help of example programs. As we know that in the overriding, the return type of subclass method must be the same as the superclass method return type.…