exam questions

Exam 1z0-819 All Questions

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

Exam 1z0-819 topic 1 question 5 discussion

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

Given the code fragment:

What is the result?

  • A. 0 8 10
  • B. 0
  • C. The code prints nothing.
  • D. 0 4 9
  • E. 0 8
Show Suggested Answer Hide Answer
Suggested Answer: E 🗳️

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
APJ1
1 year ago
Selected Answer: E
E is correct
upvoted 1 times
...
james2033
1 year, 2 months ago
Selected Answer: E
public class Foo { public static void main(String[] args) { for (var i = 0; i < 10; i++) { switch (i % 5) { case 2: i *= 2 * i; break; case 3: i++; break; case 1: case 4: i++; continue; default: break; } System.out.print(i + " "); i++; } } } // Result: // 0 8
upvoted 2 times
...
Lebannin
1 year, 5 months ago
Selected Answer: D
i=0 -> 0%5 is 0 so we go to default and break, then print 0 and increment it, so the next iteration will have i = 2. I=2 -> 2%5 is 2 so we double I then break from the loop with I = 4 print 4, increment to 5 and continue. I=6 -> 6%5 is 1 so we just increment and continue (go to the next iteration) I=8 -> 8%5 is 3 so we just increment to 9 and break, print 9 then increment and reach 10 which is the end. So the answer is D.
upvoted 1 times
...
Stavok
1 year, 7 months ago
Selected Answer: E
E is correct
upvoted 1 times
...
AlanRM
1 year, 9 months ago
Selected Answer: E
E is correct
upvoted 1 times
...
pikosss
1 year, 10 months ago
E is correct i*= 2*i; -> i=2x2x2 -> 8
upvoted 2 times
...
Ankit1010
2 years ago
E is correct answer
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 ...