• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

package declaration Q

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Shubha,

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

Joyce
 
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

where can i find the K&B mock exam?



K&B Mock exam comes with the CD , when you buy that book.
 
Ranch Hand
Posts: 1608
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Given the criteria of "most accurate", the provided answer is certainly correct. That is, 'com.animal.Cat' is not the most accurate package declaration.
 
Joyce Lee
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[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 ]
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
'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
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
accurate is not the right word to use, i agree with that

have a great day
dror
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I love a woman who dresses in stainless steel ... and carries tiny ads:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic