exam questions

Exam 1z0-808 All Questions

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

Exam 1z0-808 topic 1 question 209 discussion

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

Given:

Which statement is true?

  • A. The program executes and prints: 500.0
  • B. Commenting line 16 enables the program to print: Thank You! 500.0
  • C. Commenting line 13 enables the program to print: Thank You! 500.0
  • D. The program executes and prints: Thank You! 500.0
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
carloswork
2 months, 2 weeks ago
Selected Answer: B
Correct, the answer is B. If the question's source code is executed, it will throw the following exception: - Exception in "main" thread java.lang.Error: Unresolved compilation issue: continue cannot be used outside of a loop The continue statement cannot be used outside of a loop, as described in the documentation. When commenting the continue statement line, the code compiles normally and then print "Thank You! 500.0" https://docs.oracle.com/javase/tutorial/java/nutsandbolts/branch.html To test: public static void main(String[] args) { int price = 1000; int qty = 2; String grade = "2"; double discount = 0.0; switch(grade) { case "1": discount = price * 0.1; break; case "2": discount = price * 0.5; //continue; default: System.out.println("Thank You!"); } System.out.println(discount); }
upvoted 2 times
...
iSnover
3 months ago
Selected Answer: B
The answer is the letter B, notice that on line 16 the command ends with ":" instead of ";" causing the code not to compile. commenting out the line the code compiles normally.
upvoted 1 times
alex_au
3 months ago
continue cannot be outside the loop.
upvoted 1 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