Assertions

Q1: Which of the following statements is true?

A If assertions are compiled into a source file, and if no flags are included at runtime, assertions will execute by default.

B As of Java version 1.4, assertion statements are compiled by default.

C With the proper use of runtime arguments, it is possible to instruct the VM to disable assertions for a certain class, and to enable assertions for a certain package, at the same time.

D When evaluating command-line arguments, the VM gives -ea flags precedence over -da flags.

ANS:C - With the proper use of runtime arguments, it is possible to instruct the VM to disable assertions for a certain class, and to enable assertions for a certain package, at the same time.

Option C is true because multiple VM flags can be used on a single invocation of a Java program. Option A is incorrect because at runtime assertions are ignored by default. Option B is incorrect because as of Java 1.4 you must add the argument -source 1.4 to the command line if you want the compiler to compile assertion statements. Option D is incorrect because the VM evaluates all assertion flags left to right.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.