This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Assertion enable or not? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Assertion enable or not?" Watch "Assertion enable or not?" New topic
Author

Assertion enable or not?

Roger Zhao
Ranch Hand

Joined: Aug 05, 2003
Posts: 73
Hi,all:

What is the result?
A. finished
B. Compilation fails.
C. An AssertionError is thrown.
D. An AssertionError is thrown and finished is output.
Answer: A
Assert statement is ignored because it is disabled during normal program run by default. The choice is the result of this reason, right?
If so, when we meet the Questions with assert statement like this, how can we handle them? Think them in default (disable) or not?

Thanks,
Roger


"There is a will,there is a way!"<br />SCJP1.4
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
If so, when we meet the Questions with assert statement like this, how can we handle them? Think them in default (disable) or not?
If you get a question with only this information, then answer is A because assertions are disabled by default.
You will be explicitly notified when assertions are enable. Or you can also get:
"assuming the code is compiling using java -source 1.4, and java -ea blah blah".
[ September 02, 2003: Message edited by: Andres Gonzalez ]

I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
Anupam Sinha
Ranch Hand

Joined: Apr 13, 2003
Posts: 1088
Hi Roger
You probably won't get questions like this with incomplete information.
Hanna Habashy
Ranch Hand

Joined: Aug 20, 2003
Posts: 532
hi:
In the exam questions they always tells you if you should assume essertion is enabled or not.


SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
Roger Zhao
Ranch Hand

Joined: Aug 05, 2003
Posts: 73

In the exam questions they always tells you if you should assume essertion is enabled or not.

I got it, thank you all!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Assertion enable or not?