
Method Overloading Tricky Questions :
1. class Test { void show ( int a ) { } void show ( long a ) { } public static void main ( String [] args ) { Test t = new Test (); t . show ( 10 ); } } ANSWER: show(int a) 2. class Test { void show ( Integer a ) { } void show ( int a ) { } public static void main ( String [] args ) { Test t = new Test (); t . show ( 10 ); } } ANSWER: show(int a) 3. class Test { void show ( int a , float b ) { } void show ( float a , int b ) { } public static void main ( String [] args ) { Test t = new Test (); t . show ( 10 , 10 ); } } ANSWER: Compile-time Error 4. class Test { void show ( int ... a ) { } void show ( int a ) { } public static void main ( String [] args ) { Test t = new Test (); t . show ( 10 ); } } ANSWER: show(int a) 5. class Test { void show ( int a ) { } void show ( int ... a ) { } public static void main ( String [] args ) { Test t = new Test (); t . show (); } } ANSWER: show(int... a) 6. class Test { void show ( double a ) { } void show ( float a ) { } public static void main ( S
Continue reading on Dev.to
Opens in a new tab

