Q: Which of the following pairs of methods will cause a compile-time error due to incorrect method overloading?
-
A
void test(int a, int b) and void test(double a, double b)
-
B
void test(int a, double b) and void test(double a, int b)
-
C
void test(int a, double b) and void test(int a)
-
D
void test(int a) and int test(int a)
D
Answer:
D
Explanation:
(d) void test(int a) and int test(int a)
Explanation: Method overloading is based on method signatures (method name + parameter list). Return type differences (void vs. int) do not differentiate overloaded methods, leading to a compilation error.
Related Topic:
Share Above MCQ