File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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


janne kallio

Joined: Oct 13, 2003
Posts: 16
Hi again!
I am having problems with figuring out the usage of Java's asssertions. I know that they are primarily intended for testing reasons and they can disabled/enabled etc.
But can anyone of you give me an example how these assertions related things can be tested in the exam? Can f.ex anyone that already has passed the programmer test, recall from their experiences how this feature was tested in their particular exam?
I would appreciate your experiences very much!
Cathy Song
Ranch Hand

Joined: Aug 24, 2003
Posts: 270
Hi Janne,
Look at the questions related to assertions Dan has posted on this site:
These will give you an idea about the type of questions to expect on the exam.
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
Remember that assertions are disabled by default!!!

I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Questions can be asked on the appropriate use of assertions. For example, they might show a public method where assertions are used to validate passed parameters and ask if this is a valid use of assertions.

Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Doug Dunn
Ranch Hand

Joined: Aug 03, 2003
Posts: 66
My first column in the Java Developer's Journal was "Using Assertions". You can read it at Even experienced programmers are sometimes not sure when to use assertions. It is a difficult subject.

Download a copy of <a href="" target="_blank" rel="nofollow"><i>"Mastering The Fundamentals of The Java Programming Language"</i></a>
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8927

I am not sure how many use Assertions in their programs.
[ October 22, 2003: Message edited by: Pradeep Bhat ]

Jeff Bosch
Ranch Hand

Joined: Jul 30, 2003
Posts: 805
I have a C background, and I have to do some stuff in C++. I celebrated when Sun added assertions because I found them invaluable in testing C/C++ code to make sure things don't break from passing invalid arguments, etc. Because Java doesn't permit conditional compilation as such, assertions are the closest tool the Java programmer gets to a conditional compilation.
Remember, assert is a programmer/tester debugging and testing tool; don't put any code in your assertions that the program relies on. I think that once the Java community appreciates the power of assertions, they (assertions) will be much more widely used and understood.

Give a man a fish, he'll eat for one day. Teach a man to fish, he'll drink all your beer.
Cheers, Jeff (SCJP 1.4, SCJD in progress, if you can call that progress...)
I agree. Here's the link:
subject: assertions
It's not a secret anymore!