Which code fragment should be added at line n1 to express this invariant condition?

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" ;

Download Printable PDF. VALID exam to help you PASS.

3 thoughts on “Which code fragment should be added at line n1 to express this invariant condition?

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.