Friday, 7 September 2012

What will happen when you compile and run the following code? Public class Test { Public void myMethod (Object o) { System.out.println ( "My Object"); } Public void myMethod (String s) { System.out.println ( "My String"); } Public static void main (String args []) { Test t = new Test (); T.myMethod (null); } } | JAVA JSP

  A. The code does not compile.
  B. The code compiles cleanly and shows "My Object."
  C. The code compiles cleanly and shows "My String"
  D. The code throws an Exception at Runtime.

  Ans: C

No comments: