• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how important is assertion

 
megha kanth
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

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
 
Sanyev Babu
Ranch Hand
Posts: 132
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Sanyev
 
megha kanth
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

thx
megha
 
Raja Chandrasekaran
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An assert statement can take any of the two forms below:

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

Where,
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 !!

-Raja
passed SCJP2 last week.....
 
Robert Miller
Ranch Hand
Posts: 56
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 187
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question is to Robert. Forgive me if I am deviating.
What was ur score?
And did you take these mock tests-http://www.danchisholm.net/
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
Posts: 56
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Robert
 
siva raju
Ranch Hand
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic