Welcome Guest | Sign in | Register
Assertions - Discussion Page For Q.2543 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Assertions > Questions and Answers

Q: Which of the following statement is true about the assert statement. Select the one correct answer. 
A. If a Java class contains assert statements, then it must be compiled with -1.4 option.  B. When a program having assertions is run, -assertion option must be specified, otherwise the assertions get ignored. 
C. A possible syntax of assert statement is assert logical_expression If logical_expression evaluates to true, the program generates an AssertionError.  D. The program terminates on its first AssertionError.

Answer and Explanation

Answer:The program terminates on its first AssertionError.

Explanation:
The option A is incorrect, as the Java compiler option is -source 1.4 . The option B is incorrect, as the runtime option is -ea or -enableassertions. If the logical expression evaluates to false, then the program generates an AssertionError, hence C is incorrect.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.