• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Assertion enable or not?

 
Roger Zhao
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Anupam Sinha
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Roger
You probably won't get questions like this with incomplete information.
 
Hanna Habashy
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi:
In the exam questions they always tells you if you should assume essertion is enabled or not.
 
Roger Zhao
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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

I got it, thank you all!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic