aspose file tools*
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
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "assertions" Watch "assertions" New topic
Author

assertions

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
Sheriff

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
Enjoy!
[ 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
http://java.sun.com/j2se/1.4.1/docs/guide/lang/assert.html
http://www.fawcette.com/javapro/2002_11/online/assert_jstreet_11_14_02/
http://javaboutique.internet.com/tutorials/assertions/
- 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
http://www.enterprisedeveloper.com/jcertify
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: assertions
 
Similar Threads
Efficient text replacement
replacement and refinement
Is there a pattern to simulate multi-thread in EJB?
WA #1.....word association
Section 2 mock test questions