Given:
class MyClass{ //from ww w . j a va2 s .co m void method1 (int x){ System.out.println ("method1 int"); } void method1 (double x){ System.out.println ("method1 double"); } void method1 (String x){ System.out.println ("method1 String"); } } public class Main { public static void main (String [] args) throws Exception { MyClass ot = new MyClass (); ot.method1 (1.0); } }
What will be the output?
Select 1 option
Correct Option is : C
method1 () is overloading for three different argument types.
So when you call ot.method1 (1.0), the one with argument of type double will be invoked.