Oracle
1Z0-808 · Question #52
1Z0-808 Question #52: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-808 to reveal the answer and full explanation for question #52. The question stem and answer options stay visible for context.
Using Loop Constructs
Question
Given the code fragment: String shirts[][] = new String[2][2]; shirts[0][0] = "red"; shirts[0][1] = "blue"; shirts[1][0] = "small"; shirts[1][1] = "medium"; Which code fragment prints red: blue: small: medium?
Options
- Afor (int index = 1; index < 2; index++) { for (int idx = 1; idx < 2; idx++) { System.out.print (shirts[index][idx] + ":"); } }
- Bfor (int index = 0; index < 2; ++index) { for (int idx = 0; idx < index; ++idx) { System.out.print (shirts[index][idx] + ":"); } }
- Cfor (String c : colors) { for (String s : sizes) { System.out.println(s + ":"); } }
- Dfor (int index = 0; index < 2;) { for (int idx = 0; idx < 2;) { System.out.print (shirts[index][idx] + ":"); } idx++; }
Unlock 1Z0-808 to see the answer
You've previewed enough free 1Z0-808 questions. Unlock 1Z0-808 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.
Topics
#2D arrays#nested loops#loop control#array indexing