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


Share on Google+Share on Google+
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 :



Related Tags for SCJP Module-4 Question-13:

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 10, 2010

Recommend the tutorial

Advertisements Advertisements