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 ]