This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes assertions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "assertions" Watch "assertions" New topic


Jui Mahajan
Ranch Hand

Joined: Jun 02, 2003
Posts: 62
1. The assert system is suitable as a general replacement for the try/catch clause.
2) The assert system is suitable as a general replacement for the if/else clause
Both the above statements are false. WHy ? I thought both sounded true

-----jui<br />scjp1.4
Jessica Sant

Joined: Oct 17, 2001
Posts: 4313

The answer is false because you can turn assertions off. You should never depend on assertions to make your program run -- they should be used during development to insure that unexpected situatioins / variable values do not occur. They are generally turned off in production (it speeds things up). So if you write your code so that it only works if Assertions are turned on... and someone goes and turnst them off... You're in a world of hurt.
Check out these two articles in the JavaRanch Newsletter, hopefully they'll give you a better understanding of the correct usage of assertions:
Cindy's Segment - Asserting Yourself in Public by Cindy Glass
Assertions - Debugging in J2SE 1.4 by Thomas Paul
[ August 15, 2003: Message edited by: Jessica Sant ]

- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
Jui Mahajan
Ranch Hand

Joined: Jun 02, 2003
Posts: 62
thanks. That was good help
David Brafford
Ranch Hand

Joined: Feb 11, 2001
Posts: 91
You may also like
- Dave
Considering the Certified Java Programmer Exam?
Get JCertify 7.0!
New integration with Beanshell
Integrated context sensitive explanations and content from
Eckel, Baldwin, and Green
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: assertions
Similar Threads
Is there a pattern to simulate multi-thread in EJB?
WA #1.....word association
replacement and refinement
Section 2 mock test questions
Efficient text replacement