Vidyalelo
Java Programming · Q22

Overriding and Overloading

Programming · Java Programming · question 22

Q22

In Java, can a subclass overload a method from its superclass?

A.
Yes, as long as the method is marked as "private"
B.
No, method overloading is not allowed in Java
C.
No, method overloading is not supported
D.
None of These
Answer

Answer: Option D

Solution

Answer: Option D
Solution:
Method overloading occurs when two or more methods in the same class (or subclass and superclass) have the same name but different parameter lists.

In Java, a subclass can overload a method from its superclass by defining a method with the same name but a different parameter list.

Option A is incorrect because a method marked as private in the superclass is not visible to the subclass, so it cannot be directly overloaded.

Option B and C are incorrect because method overloading is a fundamental feature of Java and is fully supported.

Therefore, the correct answer is Option D: None of These since none of the given options correctly describe method overloading in Java.