• Post Reply Bookmark Topic Watch Topic
  • New Topic

Question on Package  RSS feed

 
Kelvin Okornoe
Ranch Hand
Posts: 48
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please, I need an explanation on why my answer was wrong, and what the answer should have been with explanation.
Any contribution to  it will be highly appreciated.
Thank very much.
CaptureJavaRanch.PNG
[Thumbnail for CaptureJavaRanch.PNG]
This an image of the question
 
Liutauras Vilda
Sheriff
Posts: 4914
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question in my opinion is badly constructed for the next reason: it doesn't say anything about your 'present working directory'.
So the possible answers per my understanding are: A, C and D
A would be correct if you'd be at '/' directory
C would be correct if you'd be at '/programs/' directory
D would be correct if you'd be at '/programs/mine/' directory

 
Liutauras Vilda
Sheriff
Posts: 4914
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch!
 
PatrickAlex Silva
Greenhorn
Posts: 2
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question acctually says "...if we compile from programs?"
Answer A
 
Liutauras Vilda
Sheriff
Posts: 4914
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PatrickAlex Silva wrote:The question acctually says "...if we compile from programs?"
Answer A
If it says that, then answer is C
 
Roel De Nijs
Sheriff
Posts: 11338
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should always QuoteYourSources when posting a question or code snippet...
 
Kelvin Okornoe
Ranch Hand
Posts: 48
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roel De Nijs wrote:You should always QuoteYourSources when posting a question or code snippet...


The question was from whizlabs.com.
 
Kelvin Okornoe
Ranch Hand
Posts: 48
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Liutauras Vilda wrote:
PatrickAlex Silva wrote:The question acctually says "...if we compile from programs?"
Answer A
If it says that, then answer is C


Please how does the phrase  ".....if we compile from programs" change the answer to the question.
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kelvin Okornoe wrote:
Please how does the phrase  ".....if we compile from programs" change the answer to the question.


In my opinion, there are just too many assumptions to this question.... but, I guess it is acceptable. First, you have to assume that the classpath is not set -- neither the environment variable or the -cp switch. This means that the classpath is the default (current) directory. And since you are compiling from the programs directory, the classpath is the "programs" directory.

Second, you have to assume that you are following the norm in compiling -- not using the source or target switches of the compiler.

Given these assumptions, the answer is option C -- as that would be the best location to compile, based on that package.

Henry 
 
Liutauras Vilda
Sheriff
Posts: 4914
334
BSD
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kelvin Okornoe wrote:
Liutauras Vilda wrote:
PatrickAlex Silva wrote:The question acctually says "...if we compile from programs?"
Answer A
If it says that, then answer is C


Please how does the phrase  ".....if we compile from programs" change the answer to the question.

If you're in programs directory currently, then what you see (being in "programs") is:
.../mine/whiz/Fan.java

So, package statement needs to reflect that directory structure.
 
Kelvin Okornoe
Ranch Hand
Posts: 48
2
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much guys for your contributions, they were very helpful and am very grateful for all your individual responses and priceless contributions.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!