In the Master Exam I came across a question with some code containing 2 assert statements. The text of the question did not reference the assert statements and did not indicate that asserts had been enabled...it just asked "What is the result?"
1 - for the exam if the code contains assert statements but nothing is said about whether or not they are enabled should we assume that they are not?
2 - if asserts are not enabled does this mean they will not be executed or only that they will execute but not cause an assert exception?
SCJP 6 88%
skipping SCJD to work on passing SCWCD
Joined: Dec 16, 2008
1. In Java 1.6 assertions are enabled by default at compile time, but at runtime they are disabled unless you enable them explicitly.
2. When you don't enable assertions at the java command line that means the JVM will bypass assertion code (it is as if it hadn't been coded.) [ December 30, 2008: Message edited by: Ruben Soto ]
All code in my posts, unless a source is explicitly mentioned, is my own.