exam questions

Exam 1z0-803 All Questions

View all questions & answers for the 1z0-803 exam

Exam 1z0-803 topic 1 question 186 discussion

Actual exam question from Oracle's 1z0-803
Question #: 186
Topic #: 1
[All 1z0-803 Questions]

Given the code fragment:

Which code fragment, when inserted at line //insert code here, enables the code to print COJ?

  • A. int i = 0; for (String[] sub: arr) { int j = sub.length -1; for (String str: sub) { System.out.println(str[j]); i++; } }
  • B. private static void doPrint() { for (int i = 0;i < arr.length;i++) { int j = arr[i].length-1; System.out.print(arr[i][j]); } }
  • C. int i = 0; for (String[] sub: arr[][]) { int j = sub.length; System.out.print(arr[i][j]); i++; }
  • D. for (int i = 0;i < arr.length-1;i++) { int j = arr[i].length-1; System.out.print(arr[i][j]); i++;
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️
Incorrect:
not A: The following line causes a compile error:
System.out.println(str[j]);
Not C: Compile erro line:
for (String[] sub: arr[][])
not D: Output: C

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Currently there are no comments in this discussion, be the first to comment!
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...