Multiple choice

Which of the following conditions is incorrect for performing overriding of methods in Java?

  1. The method name in subclass must be identical to that of the superclass method.

  2. The return type of both the methods must be different.

  3. Methods of the superclass declared as public cannot be overrided using private keyword in the subclass.

  4. An overriding method cannot raise more exceptions than those raised by superclass.

  5. The overrided methods cannot have different number of arguments.

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

This is an incorrect condition as for overriding of methods they must have same return type, both in superclass and subclass.