| Author |
Assertion question from Dan's exam
|
shweta mathur
Ranch Hand
Joined: Sep 23, 2002
Posts: 109
|
|
http://www.danchisholm.net/dec04/topic/section2/assertions2.html Question 9 Which statements are true? a. With assertions enabled it prints an AssertionError message. b. With assertions enabled it prints nothing. c. With assertions disabled it prints an AssertionError message. d. With assertions disabled it prints nothing. e. An assertion should not be placed at any location that the programmer believes will never be reached under normal operating conditions. f. The assert statement is being used to check a control-flow invariant to verify that the control flow never reaches a point in the program. g. A compiler error is generated. h. None of the above. According to the answers option "f" is correct But in this code assert statement is placed at a place where it will always be called no matter what is the value of b1,b2,b3, since there are no return statements in the if-the-else statements. I feel "f" may not be the correct option. Dan can you pls confirm !
|
--Shweta<br />SCJP 1.4 <br />SCWCD
|
 |
Dan Chisholm
Ranch Hand
Joined: Jul 02, 2002
Posts: 1865
|
|
Shweta, You are correct. The assert statement should be in an "else" block as shown below. The correct answers are still A,D and F. I will upload the correction. Thank you!
|
Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
|
 |
shweta mathur
Ranch Hand
Joined: Sep 23, 2002
Posts: 109
|
|
Thanks Dan ! Your questions are really interesting to work on ! Shweta
|
 |
 |
|
|
subject: Assertion question from Dan's exam
|
|
|