Oracle
1Z0-809 · Question #200
1Z0-809 Question #200: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-809 to reveal the answer and full explanation for question #200. The question stem and answer options stay visible for context.
Question
Given: class Engine { double fuelLevel; Engine(int fuelLevel) { this.fuelLevel = fuelLevel; } public void start() { // line n1 System.out.println("Started"); } public void stop() { System.out.println("Stopped"); } } 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?
Options
- Aassert fuelLevel > 0; "Terminating...";
- Bassert (fuelLevel > 0) : System.out.println("Impossible fuel");
- Cassert fuelLevel < 1: System.exit(0);
- Dassert fuelLevel > 0: "Impossible fuel";
Unlock 1Z0-809 to see the answer
You've previewed enough free 1Z0-809 questions. Unlock 1Z0-809 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.