exam questions

Exam 1z0-809 All Questions

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

Exam 1z0-809 topic 1 question 102 discussion

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

Given:

Your design requires that:
✑ fuelLevel of Engine must be greater than zero when the start() method is invoked.
✑ The code must terminate if fuelLevel of Engine is less than or equal to zero.
Which code fragment should be added at line n1 to express this invariant condition?

  • A. assert (fuelLevel) : "Terminating"¦";
  • B. assert (fuelLevel > 0) : System.out.println ("Impossible fuel");
  • C. assert fuelLevel < 0: System.exit(0);
  • D. assert fuelLevel > 0: "Impossible fuel" ;
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

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
maslac
Highly Voted 3 years, 9 months ago
Correct answer is D Condition must evaluate to false for execution of program to terminate
upvoted 12 times
...
HanenBA
Highly Voted 2 years, 11 months ago
Selected Answer: D
the correct code for assertion is assert (condition): "customized string message"; if condition is false then a runtime exception will be thrown with the customized string message correct answer is D
upvoted 5 times
...
DarGrin
Most Recent 8 months ago
Selected Answer: D
Correct answer D
upvoted 1 times
...
steefaand
11 months, 3 weeks ago
Selected Answer: D
D is correct, as assert takes boolean (eliminating a) and it has to evaluate to false in order for Error to be thrown.
upvoted 1 times
...
Eden0516
1 year, 10 months ago
Selected Answer: D
Correct answer is (D), tested
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 ...