This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

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
java Antique

2) javac
java -ea Antique

3) javac -source 6
java Antique

4) javac -source 1.4
java Antique

5) javac -source 1.6
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: 4541

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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Assertion problem
It's not a secret anymore!