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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

uestion on Assertion

 
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Question:
Which two of the followig statements are false? (Choose two)
A. It is never good practice to place assertions where you think execution should never reach.
B. It is never good practice to throw an AssertionError explicitly.
C. Use assertions to verify the arguments of private methods.
D. Don't use assertions to verify the arguments of public methods.
E. Don't handle AssertionErrors with a try-catch block.
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
A. It is never good practice to place assertions where you think execution should never reach.
FALSE - it�s a GOOD practice to place assertions (IN DESIGN FASE) where you think execution should never reach.
E. Don't handle AssertionErrors with a try-catch block.
FALSE - AssertionErrors should never be handled

The other statements:
B. It is never good practice to throw an AssertionError explicitly
CORRECT - it is sometimes advisable to thrown an assertion error even if assertions have been disabled
C. Use assertions to verify the arguments of private methods.
CORRECT - for private methods is ok, but don�t use in PUBLIC methods
D. Don't use assertions to verify the arguments of public methods.
CORRECT - see above
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
this is an accidental duplicate -- check out complete conversation here.
    Bookmark Topic Watch Topic
  • New Topic