exam questions

Exam 1z0-808 All Questions

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

Exam 1z0-808 topic 1 question 169 discussion

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

Given the code fragment:

What is the result?

  • A. A B C
  • B. A B C D E
  • C. A B D E
  • D. Compilation fails.
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

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
SSJ5
Highly Voted 3 years, 8 months ago
correct answer is C
upvoted 11 times
...
mete23
Highly Voted 4 years, 10 months ago
Agree, the correct answer C public class Test { public static void main(String[] args) { String[][] arr = { { "A", "B", "C" }, { "D", "E"} }; for (int i = 0; i < arr.length; i++) { for (int j = 0; j < arr.length; j++) { System.out.print(arr[i][j] + " "); if (arr[i][j].equals("B")) { break; } } continue; } } }
upvoted 6 times
Harid
4 years, 3 months ago
Interestingly your code is wrong, but giving right answer. Inner loop should be like this: j<arr[i].length; (NOT j<arr.length; )
upvoted 3 times
...
TOPPSI
1 year, 11 months ago
Thats wrong two mistakes in the code. One is in the scond loop it is not arr.length it is arr[i].length. Next mistake used an Break instate a continue. The right anwser is B I Test it
upvoted 1 times
...
...
MPignaProTech
Most Recent 1 month, 3 weeks ago
Selected Answer: C
j must be lower than 3 and 2 so the possible values for jare 0-1 Correct answer is C
upvoted 1 times
...
DriftKing
1 year, 3 months ago
Selected Answer: B
Tested. Answer is (B) A B C D E
upvoted 1 times
...
dsms
1 year, 3 months ago
Selected Answer: C
correct answer is C: A B D E
upvoted 1 times
dsms
1 year, 3 months ago
after update correct answer is : A B C D E
upvoted 2 times
...
...
sina_
1 year, 4 months ago
Selected Answer: B
print is before if so it print everything
upvoted 2 times
...
examprepincedo
1 year, 10 months ago
Selected Answer: B
Ans is B
upvoted 1 times
...
amigo31
2 years ago
I tested it.The answer is B.
upvoted 1 times
...
carloswork
2 years, 1 month ago
Selected Answer: B
Answer is B. Correct source code for test: public static void main(String[] args) { String [][] arr = {{ "A", "B", "C" }, { "D", "E" }}; for (int i = 0; i < arr.length ; i++) { for(int j = 0; j < arr[i].length; j++) { System.out.print(arr[i][j] + " "); if (arr[i][j].equals("B")) { continue; } } continue; } } -------------------------------------------------------- The confusion between the answers is in the second "for" in the source code of the question, the "for" that increments 'j'. This is the correct 'for' of the question: for (int j = 0; j < arr[i].length; j++) This is the incorrect 'for' that generates "Answer is C": for (int j = 0; j < arr.length; j++)
upvoted 2 times
...
UAK94
2 years, 2 months ago
Correction: The answer is B. Here is the right code and it is tested. String[][] arr = { { "A", "B", "C" }, { "D", "E"} }; for (int i = 0; i < arr.length; i++) { for (int j = 0; j < arr[i].length; j++) { System.out.print(arr[i][j] + " "); if (arr[i][j].equals("B")) { continue; } } continue; }
upvoted 3 times
...
UAK94
2 years, 2 months ago
String[][] arr = { { "A", "B", "C" }, { "D", "E"} }; for (int i = 0; i < arr.length; i++) { for (int j = 0; j < arr.length; j++) { System.out.print(arr[i][j] + " "); if (arr[i][j].equals("B")) { continue; } } continue; } Result is A B D E
upvoted 3 times
...
alex_au
2 years, 2 months ago
Selected Answer: B
The question has been changed. Now the "continue" inside the if-block has no any effect as there is no other code to execute after the if-block. It is the same as outputing all the elements inside the arrays.
upvoted 1 times
...
iSnover
2 years, 2 months ago
Selected Answer: C
The correct answer is letter C, pay attention to the continues inside the for loops.
upvoted 1 times
...
XalaGyan
2 years, 10 months ago
Selected Answer: C
C is correct
upvoted 1 times
...
brianhuang881215
3 years, 3 months ago
D correct
upvoted 1 times
...
v323rs
4 years, 11 months ago
Agree, the correct answer C. A B D E
upvoted 4 times
...
letmein2
5 years, 6 months ago
Correct.
upvoted 2 times
...
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 ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago