Home Tutorial Java Scjp Part4 SCJP Module-4 Question-13

 
 

SCJP Module-4 Question-13
Posted on: July 10, 2010 at 12:00 AM
The program given below tests your knowledge of method overloading in Java.

Given below the sample code :

1. class Example13

2. {

3. void Method(int i) {System.out.println("int version");}

4. void Method(String s) {System.out.println("String version");}

5. public static void main(String args[])

6. {

7. Example13 obj = new Example13();

8. char ch = 'c';

9. obj.Method(ch);

10. }

11. }

What will be the output of the following ?

1. Error at Line 4 because void methods can't be overridden.
2  Error at line 9, an exception will be thrown.
3. Prints :  int version.
4. Prints : String version.

Answer :

(4)

Related Tags for SCJP Module-4 Question-13:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.