Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Package  RSS feed

 
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a question from voodoo exam
package org . myPack ;
public class Ques01 {
// some code
};
Which of the following are valid ways of refereing to the class from any other package besides org . myPack ?
Options :
a . Refer to the class as Ques01
b . Refer to the class as org . myPack . Ques01
c . Refer to the class as myPack . Ques01
d . import org . myPack . * & then refer to the class as Ques01
e . import org . * & then refer to the class as Ques01
The ans given are b and c . I answered it as b and d.
Could anypne of you explain me the options c?
[ December 16, 2003: Message edited by: Lakshmi Saradha ]
 
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This has just got to be a mistake. It doesn't make sense to use "c", and your answers seem correct to me
cheers,
Kathy
 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I do agree that b and d are correct answers....
B is for the classes, which does not want to import the org.myPack.Ques01 at the beginning... In this case that the usage amount is less and the programmer just want to use it sometimes, the way to use Ques01 in B is reasonable...
But if the programmer wants to use the Ques01 for many times in the class, he/she should import it at the beginning of his/her class. Then he can use the Ques01 by just using "Ques01", not needed to use the whole fullpath like "org.myPack.Ques01"...
Just some more explanation from me....
 
Lakshmi Saradha
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you kathy and Ko Ko naing..

Regards,
Lakshmi.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
b , d
 
No prison can hold Chairface Chippendale. And on a totally different topic ... my stuff:
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!