Given:
What is the result?
Given:
What is the result?
The code will result in a compilation error since the class has two methods with the same name and parameter types but different return types. In Java, method overloading must differ in the number or type of parameters, but not solely based on the return type. Hence, having both public int add(int x) and public void add(int x) methods in the same class is not allowed and causes a compilation error.
Duplicate Method Signature: The class has two methods with the same name and parameter types but different return types, which is not allowed. The method add(int x) has a conflicting declaration as both public int add(int x) and public void add(int x).
same signature , that is , method with same name and same number of arguments with same type of arguments Duplicate add(int x)
same signature , that is , method with same name and same number of arguments with same type of arguments
As said above, you cannot duplicate the name of the method without changing the arguments.
This code compiles properly we can define duplicate methods it will not throw a error in compiling so correct answer is C
I tested myself and it is not compiling