Page 1 of 1

About question com.enthuware.ets.scjp.v6.2.27 (hoping reference is right)

Posted: Tue Oct 16, 2012 2:56 pm
by ALain38
The question is:
You have just written a Java class named AssertTest.java that uses the assertion facility. Write down the syntax for compiling this program using Javac.
[Do not write the classpath or any other switches, just use the one/ones that is/are absolutely needed. Start with: javac ...]
But, in the possible (right) answers, the switch -ea is never used (and it is why my own answer is declared wrong). As assertions are disabled by default how the code can "uses the assertion facility" if the switch is not present?

Re: About question com.enthuware.ets.scjp.v6.2.27 (hoping reference is right)

Posted: Tue Oct 16, 2012 3:33 pm
by admin
The question only asks about how to compile it without using any switches that not necessary. -ea is required to enable assertions at runtime. It has nothing to do with compilation. In other words, -ea doesn't apply to javac. It applies to java.

HTH,
Paul.