• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Assertion

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dan Chischolm has a bunch of topic mock exams, including assertions.
 
bobby chaurasia
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 !
 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
 
I wasn't selected to go to mars. This tiny ad got in ahead of me:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic