wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes package declaration Q 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 "package declaration Q" Watch "package declaration Q" New topic
Author

package declaration Q

Shubhada Nandarshi
Ranch Hand

Joined: Jun 10, 2005
Posts: 59
Hi friends;
see the following Q.

Whem defining a package for the class Cat,which of the following statements is most accurate?
1> package com.animal.Cat;
2>package com/animal/Cat;
3>package com.animal;
4>package com/animalll;
5>None of the above.

the ans given is option 3 ,but I think option 1 is also correct.
If I am wrong plz let me know.
----------------------------------------------------------------------------

(where can i find the K&B mock exam? )

Shubha.


Shubhada
Joyce Lee
Ranch Hand

Joined: Jul 11, 2003
Posts: 1392
Hi Shubha,

I agree with you. Though bad package naming, it's still legal to have a package called com.animal.Cat.

Joyce
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
where can i find the K&B mock exam?


K&B Mock exam comes with the CD , when you buy that book.


Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
Given the criteria of "most accurate", the provided answer is certainly correct. That is, 'com.animal.Cat' is not the most accurate package declaration.


Tony Morris
Java Q&A (FAQ, Trivia)
Joyce Lee
Ranch Hand

Joined: Jul 11, 2003
Posts: 1392
[Tony]:Given the criteria of "most accurate", the provided answer is certainly correct. That is, 'com.animal.Cat' is not the most accurate package declaration.

Well... OK, let's try another one.

Q: When defining a method for the class Cat, which of the following statement is most accurate?

1. public void Meow() { }
2. public void Meow { }
3. public void meow() { }
4. public void meow { }
5. None of the above.
[ June 25, 2005: Message edited by: Joyce Lee ]
Dror Astricher
Ranch Hand

Joined: May 20, 2005
Posts: 31
'com.animal.Cat' is not the most accurate package declaration because you will not put a file inside a folder with the file name.

take an example from outside java:

if you have a file called yellow.txt
will you put it in a folder called 'yellow' or in a folder called 'colors'?
what happens if you then have a red.txt?
it will also be ok to put it in a yellow folder but it will not be the most accurate one

have a great day
dror
Joyce Lee
Ranch Hand

Joined: Jul 11, 2003
Posts: 1392
Dror: 'com.animal.Cat' is not the most accurate package declaration because you will not put a file inside a folder with the file name.

Why not? I can place different kinds of cats and classes related to cat in that package. An example would be javax.servlet package. There is an interface called Servlet in that package. Here is another one, java.applet.

if you have a file called yellow.txt
will you put it in a folder called 'yellow' or in a folder called 'colors'?
what happens if you then have a red.txt?


Why can't I place it in a folder called yellow? Perhaps my intention is to put different shades of yellow color in that folder and not interested in other colors.

What I'm trying to say is, how a package is named depends on its context and also the coding standard the team employed.

Joyce
[ June 28, 2005: Message edited by: Joyce Lee ]
Dror Astricher
Ranch Hand

Joined: May 20, 2005
Posts: 31
hi there

if you have 4 yellow files: brightYellow, shadedYellow, dirtyYellow and yellow.
will you put them all in a folder called 'yellow' or in folders called 'yellows' or 'difYellows'? (-:

dror
Joyce Lee
Ranch Hand

Joined: Jul 11, 2003
Posts: 1392
If I choose yellow, does that make me less accurate? And if I name a method with name beginning with capital letter like Meow(), does that mean it is less accurate?

Questions which are debatable like the one posted by Shubha won't be asked in the exam. In fact, I think the question should be rephrased to something like "..., which of the following statement(s) are correct/legal?".
Dror Astricher
Ranch Hand

Joined: May 20, 2005
Posts: 31
accurate is not the right word to use, i agree with that

have a great day
dror
Saravanan Thirugnanam
Greenhorn

Joined: Jan 19, 2005
Posts: 20
Hi,

I think with the context to "Most accurate answer" the answer is certainly com.animal.In addition to what others posted,i heard that it is a convention that package names should be in all lowercase letters.But com.animal.Cat contains Cat(initcap) ,which is a convention followed for naming the classes and not for the packages.Correct me if i am wrong.


saravanan T
 
Don't get me started about those stupid light bulbs.
 
subject: package declaration Q