aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Jar file statement (true or false) 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 "Jar file statement (true or false)" Watch "Jar file statement (true or false)" New topic
Author

Jar file statement (true or false)

Ali Khalfan
Ranch Hand

Joined: Nov 03, 2007
Posts: 126
In the master exam, one of the questions says this:


A JAR file can contain classes from only a single package

This looks to be true..yet the answer guide says this is false, why can't I have one package in the archive?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41809
    
  62
What is "the master exam"? Please QuoteYourSources.

A jar file can contain classes from any number of packages.


Ping & DNS - my free Android networking tools app
Ali Khalfan
Ranch Hand

Joined: Nov 03, 2007
Posts: 126
Master Exam is a software that has questions on a cd that came with the K&B book

The statement should be true shouldn't it ?
Ali Khalfan
Ranch Hand

Joined: Nov 03, 2007
Posts: 126
ok I guess I misunderstood the question.

The only word here must mean 'A jar must only contain one file'

I hope I don't fall in the pitfall again
neil keefe
Greenhorn

Joined: Feb 15, 2010
Posts: 4
I registered in here just so that I could complain about this particular answer!

Yes, a JAR file *can* contain classes from only a single package. It can also contain classes from more than one package.

This is ambiguous at best. If they phrased it plainly:

A JAR file can only contain classes from a single package.

The answer would be too obvious. So the question is relying on ambiguity in English for its difficulty, rather than on your knowledge of the principle at play.

Alas I have only one packet of seeds. Can I plant seeds in my garden, from only a single packet? Yes, I can. And if I had many packets of seeds, I could plant seeds from many packets. It's my choice!

Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9302
    
  17

Yes, a JAR file *can* contain classes from only a single package. It can also contain classes from more than one package.

neil the book never says that the JAR file cannot contain classes from only a single package. The way I see it, the statement in the book is correct. The statement that "a JAR file can contain classes from only a single package" is wrong. This doesn't mean that the JAR file *must* contain classes from multiple package. Even you can create an empty JAR file with no classes from any package. When the book says that the statement is wrong, it means that the JAR file can contain classes from many packages, so it means >=0 i.e. it can contain classes from zero, one or more packages...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
neil keefe
Greenhorn

Joined: Feb 15, 2010
Posts: 4
Ankit I understand what the book was getting at. The problem is the statement can be interpreted another way, depending on where the emphasis is placed:

Your garden can be planted using only one packet of seeds.

Sounds like: Your garden can be planted using one and only one packet of seeds. (the author's intent--false)

Your garden can be planted using only one packet of seeds.

Sounds like: Your garden can be planted using merely one packet of seeds. (true)

When it's written we cannot see the emphasis, so there is no way to tell which version represents the writer's intent. Until you look up the answer. The fact that we commenters must resort to various *tricks* to indicate the emphasis is a clue something's wrong. So either can be valid it seems to me, depending on how you read the sentence aloud. The authors obviously meant the "one and only one" way, but I read it the "merely" way, and so did Ali and probably many others. Good thing it's only a practice question!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jar file statement (true or false)