Oracle
1Z0-809 · Question #161
Given the code fragment: int nums1[] = new int [3]; int nums2[] = {1, 2, 3, 4, 5}; nums1 = nums2; for (int x : nums1) { System.out.print(x + ":"); } What is the result?
The correct answer is B. 1 : 2 : 3 : 4 : 5. You've hit your session limit · resets 10:20pm (America/New_York)
Question
Given the code fragment:
int nums1[] = new int [3];
int nums2[] = {1, 2, 3, 4, 5};
nums1 = nums2;
for (int x : nums1) {
System.out.print(x + ":");
}
What is the result?
Options
- AAn ArrayIndexOutOfBoundsException is thrown at runtime.
- B1 : 2 : 3 : 4 : 5 :
- CCompilation fails.
- D1 : 2 : 3 :
How the community answered
(47 responses)- A6% (3)
- B77% (36)
- C13% (6)
- D4% (2)
Explanation
You've hit your session limit · resets 10:20pm (America/New_York)
Community Discussion
No community discussion yet for this question.