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
6 months, 2 weeks ago
Selected Answer: E
E is correct
upvoted 1 times
...
james2033
9 months, 1 week 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
...
[Removed]
11 months, 1 week ago
Selected Answer: E
E is correct! i = 0, 0%5 = 0, default get's hit. 0 get's printed and incremented to 1. i = 1, case 1 has no break so we increment i to 2 and continue. i=2, 2%5 = 2 so 2 * 2 *2= 8. we print 8 and increment to 9 i=9, 9%5 = 4. we increment i to 10 and continue. We exit the for loop as 10 is not smaller than 10.
upvoted 1 times
...
Lebannin
1 year 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, 2 months ago
Selected Answer: E
E is correct
upvoted 1 times
...
AlanRM
1 year, 3 months ago
Selected Answer: E
E is correct
upvoted 1 times
...
pikosss
1 year, 4 months ago
E is correct i*= 2*i; -> i=2x2x2 -> 8
upvoted 2 times
...
Ankit1010
1 year, 6 months 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 ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago