Oracle
1Z0-809 · Question #163
Given the code fragment: public static void main(String[] args) { int array[] = {10, 20, 30, 40, 50}; int x = array.length; // line n1 } Which two code fragments can be independently inserted at…
The correct answer is B. do { --x; System.out.print(array[x]); } while (x >= 0). You've hit your session limit · resets 10:20pm (America/New_York)
Question
Given the code fragment:
public static void main(String[] args) {
int array[] = {10, 20, 30, 40, 50};
int x = array.length;
// line n1
}
Which two code fragments can be independently inserted at line n1 to enable the code to print the elements of the array in reverse order?
Options
- Awhile (x > 0) { System.out.print(array[--x]); }
- Bdo { --x; System.out.print(array[x]); } while (x >= 0);
- Cdo { System.out.print(array[x]); --x; } while (x >= 0);
- Dwhile (x >= 0) { System.out.print(array[x]); --x; }
- Ewhile (x > 0) { System.out.print(array[x]); }
How the community answered
(15 responses)- B73% (11)
- C13% (2)
- D7% (1)
- E7% (1)
Explanation
You've hit your session limit · resets 10:20pm (America/New_York)
Community Discussion
No community discussion yet for this question.