wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Assertion problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Assertion problem" Watch "Assertion problem" New topic

Assertion problem

Komal Arora
Ranch Hand

Joined: Sep 30, 2010
Posts: 91

the question is from the k&S book and is as follows:

which sets of commands will compile and run without exception or error:

1) javac Antique.java
java Antique

2) javac Antique.java
java -ea Antique

3) javac -source 6 Antique.java
java Antique

4) javac -source 1.4 Antique.java
java Antique

5) javac -source 1.6 Antique.java
java -ea Antique

the answer to the above is : 1 and 3.

i understood why 1 and 3 are correct.
i understood why 4 is incorrect, which is because the code uses generics which werent introduced till java 5, hence the command statement is wrong

i did not understand why 2 and 5 are wrong! Can anyone please explain the fact!

Matthew Brown

Joined: Apr 06, 2010
Posts: 4344

Hint: Is the assertion correct? What is the length of the args array?
Komal Arora
Ranch Hand

Joined: Sep 30, 2010
Posts: 91


thanks Matthew!
I agree. Here's the link: http://aspose.com/file-tools
subject: Assertion problem
Similar Threads
Assertion again.
K&B Page 814 Q7 Regarding Assertions in Java
KB book...clarification on 1.4 and 1.5
Doubt with assertions - Kathy Sierra chapter 10