| Author |
Assertion
|
bobby chaurasia
Ranch Hand
Joined: Mar 30, 2002
Posts: 84
|
|
I came across this interesting question on assertion which I though I'd share with you all Select the one correct answer. (a) The compilation fails, because the method name assertBounds cannot begin with the keyword assert. (b) The compilation fails because the assert statement is invalid. (c) The compilation succeeds and the execution runs without errors. (d) The compilation succeeds and an AssertionError with the error message �too low� is thrown. (e) The compilation succeeds and an AssertionError with the error message �too high� is thrown. The correct answer is c. The way I attacked it was : assertion syntax : assert boolean expression : message step1 : Regroup assert ((value > low) ? (value < high) : false ) : (value < high ? "too low" : "too high"); Step 2 : Equate for low = 100, high = 200, value = 150 assert (true ? true:false) : ( true ? "Too low" : "too high" ) which is equivalent assert true : "Too low" The assert statement rightly asserts that 150 is greater than 200. BTW I'll appreciate any information on mock exams on assertion. Cheers [ Jess added UBB [code] tags to preserve whitespace, check 'em out! ] [ January 08, 2003: Message edited by: Jessica Sant ]
|
 |
Jessica Sant
Sheriff
Joined: Oct 17, 2001
Posts: 4313
|
|
|
Dan Chischolm has a bunch of topic mock exams, including assertions.
|
 |
bobby chaurasia
Ranch Hand
Joined: Mar 30, 2002
Posts: 84
|
|
Jessica, I've been taking Dans exams but I believe assertion is not covered because in the tests by topics there is nothing that deals with assertion. Thanks !
|
 |
John Paverd
Ranch Hand
Joined: Nov 17, 2002
Posts: 115
|
|
Originally posted by bobby chaurasia: Jessica, I've been taking Dans exams but I believe assertion is not covered because in the tests by topics there is nothing that deals with assertion. Thanks !
Dan's assertion test 1
|
SCJP 1.4
|
 |
Valentin Crettaz
Gold Digger
Sheriff
Joined: Aug 26, 2001
Posts: 7610
|
|
Some assertion resources: http://www.coderanch.com/t/239754/java-programmer-SCJP/certification/Notes-Assertions http://www.coderanch.com/t/239625/java-programmer-SCJP/certification/study-material-ASSERTIONS
|
SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
|
 |
 |
|
|
subject: Assertion
|
|
|