aspose file tools*
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 Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Assertion problem" Watch "Assertion problem" New topic
Author

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!


OCPJP
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4246
    
    7

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

Joined: Sep 30, 2010
Posts: 91

OH! SILLY ME!

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