Wednesday, 1 November 2017

#12. SCJP/OCJP Exams Questions & Answers-


12. Given:
 public class Barn {
public static void main(String[] args) {
 new Barn().go("hi", 1);
 new Barn().go("hi", "world", 2);
 }
public void go(String... y, int x) {
 System.out.print(y[y.length - 1] + " ");
 }
 }
What is the result?
A. hi hi
B. hi world
C. world world
D. Compilation fails.
E. An exception is thrown at runtime.


Answer: D

No comments:

Post a Comment

#45 to #51 SCJP/OCJP Exams Questions & Answers-

45. Given: 1. public class A { 2. public void doit() { 3. } 4. public String doit() { 5. return "a"; 6. } 7. ...