Home - Java Programming - Assertions

Assertions Online Exam Quiz

Important questions about Assertions. Assertions MCQ questions with answers. Assertions exam questions and answers for students and interviews.

3. Which three statements are true? Assertion checking is typically enabled when a program is deployed. It is never appropriate to write code to handle failure of an assert statement. Assertion checking is typically enabled during program development and testing. Assertion checking can be selectively enabled or disabled on a per-package basis, but not on a per-class basis. Assertion checking can be selectively enabled or disabled on both a per-package basis and a per-class basis.

Options

A : 1, 2 and 4

B : 2, 3 and 5

C : 3, 4 and 5

D : 1, 2 and 5

4. Which statement is true?

Options

A : Assertions can be enabled or disabled on a class-by-class basis.

B : Conditional compilation is used to allow tested classes to run at full speed.

C : Assertions are appropriate for checking the validity of arguments in a method.

D : The programmer can choose to execute a return statement or to throw an exception if an assertion fails.

6. Which statement is true about assertions in the Java programming language?

Options

A : Assertion expressions should not contain side effects.

B : Assertion expression values can be any primitive type.

C : Assertions should be used for enforcing preconditions on public methods.

D : An AssertionError thrown as a result of a failed assertion should always be handled by the enclosing method.

Java Programming more Online Exam Quiz

Copyright © 2021
Exam-GK-MCQ-Questions.Com | Contact Us | Privacy Policy | Terms of Use | Sitemap | 0.018409013748169