Which of the following pairs of methods will cause a compile-time error due to incorrect method overloading?

ICSE Class 10 Computer Applications PYQ · 2025 Paper · Section A

1(xv)1 Mark · 2025 · Section A · 2025 Paper

Which of the following pairs of methods will cause a compile-time error due to incorrect method overloading?

Show SolutionHide Solution↓

void test(int a) and int test(int a)

Reason — In Java, method overloading depends on the method's name and its parameter list (number or type of parameters). The return type alone is not considered for method overloading. So, void test(int a) and int test(int a) have the same name and same parameter list, which causes a compile-time error because they differ only in return type, not in parameters.

← Previous questionNext question →

Share on WhatsApp

Browse the free Computer Applications sample bank