1. Home
  2. Computing & Technology
  3. Computer Certification

Question 16

What results from the following code?

1.         class MyClass

2.         {

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

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

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

6.                     {

7.                                 MyClass obj = new MyClass();

8.                                 char ch = 'c';

9.                                 obj.myMethod(ch);

10.                   }

11.       }

 

Line 4 will not compile as void methods can't be overridden.
An exception at line 9
Line 9 will not compile as there is no version of myMethod, which takes a char as argument.
The code compiles and produces output: int version.
The code compiles and produces output: String version.

Back to beginning | Next Question



Explore Computer Certification
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Computer Certification

©2009 About.com, a part of The New York Times Company.

All rights reserved.