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 how important is assertion 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 "how important is assertion" Watch "how important is assertion" New topic

how important is assertion

megha kanth
Ranch Hand

Joined: Mar 10, 2004
Posts: 44

Can anyone tell as how important is assertion topic and arnd how many questions can I expect from this.

I am little weak in this hence was thinking to skip it.


Megha Kanth<br />SCJP 1.4
Sanyev Babu
Ranch Hand

Joined: Dec 18, 2003
Posts: 132
Hi Megha,
Don't skip assertions. It is an easy topic and very easy to score in assertion questions. you will get two or three questions in this topic. May be less but don't skip this topic. You won't need more than half an hour to get a good idea of assertions. To get a good score each question counts so don't skip anything.
megha kanth
Ranch Hand

Joined: Mar 10, 2004
Posts: 44
Hi Sanyev

Thx for the reply. I will cover that topic and try to cover other topic also.

I am planning to give the exam next week, so is there any quick revision notes which i can go thru. K&B book 2 minute drill is very good and i will go thru that but is there something else also.

Raja Chandrasekaran

Joined: Jun 20, 2004
Posts: 10
An assert statement can take any of the two forms below:

assert Expression1; //1st Form
assert Expression1 : Expression2; //2nd Form

Expression1 - is a boolean expression.
Expression2 - is a information expression, which could be of any data type.

Note: When Expression1 evaluates to false, then the program generates an Assertion Error or else not.
Yeah I too agree Assertion are very easy, initially I also thought of skiping it but, once I got the above syntax clear in my mind...I never made any mistake.......always remember the Expression1 should finally return boolean and Expression2 should return any data except "void". Some time in place of Expression2 a function could be called that returns void type. This will be a compiler error.

In exam you could except one to two questions on assertion. Some time they ask you where assertions should be used....

All the Best !!

passed SCJP2 last week.....
Robert Miller
Ranch Hand

Joined: Jun 18, 2004
Posts: 56
I took the test last week and I think I got somewhere around 5 questions on assertions. Based on the questions I got and the practice questions I've seen, I would recommend that you:

1. Know the format of an assertion statement and what it does.
2. Understand the difference between appropriate and inappropriate use of assertions.
3. Know how to use -ea, -da, -esa, and -dsa to enable assertions for specific classes and packages at runtime.
4. Know how to use a compile option to compile assertion statements into your code.

Most of the above aren't tricky.
Swamy Nathan
Ranch Hand

Joined: May 16, 2004
Posts: 187
This question is to Robert. Forgive me if I am deviating.
What was ur score?
And did you take these mock tests-
I seem to be averagin in my mock tests lower than what I hope to score in the actual.
What do u think of the mock tests?
[ June 21, 2004: Message edited by: Swamy Nathan ]
Robert Miller
Ranch Hand

Joined: Jun 18, 2004
Posts: 56
I got 100% on the exam, believe it or not. I say "believe it or not" because I think it means my educated guesses were either very educated or very lucky.

I took three of the comprehensive exams on Dan Chisholm's site. In general all of the mock exams I took were slightly harder than the actual test, although that could be because I learned something from every question I got wrong.

siva raju
Ranch Hand

Joined: Oct 10, 2003
Posts: 37
I got about 4 questions on assertions. Apart from what robert and raja have already listed, there isn't much regarding assertions. But I would like to assert the following points again,

1) In
assert expr1 : expr2

expr2 can be anything with a return type expect a void type. So if its a boolean expr like (5==6)
you get an output with "false" and an AssertionError(if applicable)

2) Though a simple point, do not forget that unless you enable assertions in the execution, you will not see any assertion outputs.

Siva<br />-----<br />SCWCD 1.4, SCJP 1.4, SCBCD(Preparing), CCNA
I agree. Here's the link:
subject: how important is assertion
jQuery in Action, 3rd edition