Exams Knowledge Hub

MCQs for Competitive Exams, School & College Exams

Module: | Core Architecture, Basics & Control Flow

Q21: Consider the following statements regarding Method Overloading:

1. Method overloading is a manifestation of compile-time polymorphism where multiple methods share the same name but possess different parameter lists.
2. The Java compiler permits method overloading based exclusively on differing return types, even if the parameter lists are absolutely identical.
3. Method overloading allows different methods to vary by the number of input parameters, the data type of the input parameters, or the sequence of the input parameters.

Which of the above statements is/are correct?
A
Only 1 and 2
B
Only 1 and 3
C
Only 2 and 3
D
1, 2, and 3
✅ Correct Answer: B
🎯 Quick Answer:
The correct combination is 1 and 3. Statement 2 is incorrect because altering only the return type creates an ambiguous state for the compiler; method overloading mandates a physical modification of the parameter list.
Concept Definition: Method Overloading is a compile-time polymorphism technique where multiple methods within the same class share identical names but possess strictly distinct parameter signatures.
Structural Breakdown: The compiler distinguishes overloaded methods by analyzing the number of arguments, the sequence of argument data types, and the specific data types themselves.
Historical/Related Context: Overloading heavily improves API readability.
Before overloading existed in older procedural languages, programmers had to invent awkward, distinct names for mathematically identical operations.
Java unified this into a single cohesive naming concept.
Causal Reasoning: The Java compiler refuses to overload based solely on return types because method calls frequently ignore the returned value.
If a program simply executed a method without assigning its result, the compiler would have absolutely no mathematical or contextual way to determine which version of the method the developer intended to invoke.