Question
Which of the following statements is true?
Answer: Option B
Was this answer helpful ?
Adding an assertion statement to a switch statement that previously had no default case is considered an excellent use of the assert mechanism.
Option A is incorrect because only Java expressions that return a value can be used. For instance, a method that returns void is illegal.
Option C is incorrect because the expression after the colon must have a value.
Option D is incorrect because assertions throw errors and not exceptions, and assertion errors do cause program termination and should not be handled.
Was this answer helpful ?
More Questions on This Topic :
Question 1.
Which of the following statements is true?
....
Question 3.
Which statement is true?
....
Question 4.
Which of the following statements is true?
....
Question 8.
public class Test
{
public void foo()
{
....
Submit Solution