Oracle
1Z0-851 · Question #111
Given: 1. public class Venus { 2. public static void main(String[] args) { 3. int[] x = { 1, 2, 3 }; 4. int y[] = { 4, 5, 6 }; 5. new Venus().go(x, y); 6. } 7. 8. void go(int[]... z) { 9. for (int[]…
The correct answer is C. 14. See the full explanation below for the reasoning.
Question
Given: 1. public class Venus { 2. public static void main(String[] args) { 3. int[] x = { 1, 2, 3 }; 4. int y[] = { 4, 5, 6 }; 5. new Venus().go(x, y); 6. } 7. 8. void go(int[]... z) { 9. for (int[] a : z) 10. System.out.print(a[0]); 11. } 12.} What is the result?
Options
- A1
- B12
- C14
- D123
- ECompilation fails.
- FAn exception is thrown at runtime.
How the community answered
(21 responses)- C86% (18)
- D5% (1)
- F10% (2)
Community Discussion
No community discussion yet for this question.