This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Assertion question from Dan's exam Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Assertion question from Dan Watch "Assertion question from Dan New topic
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Assertion question from Dan's exam