Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Question on Package

 
Ranch Hand
Posts: 130
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
 
Sheriff
Posts: 7647
522
Mac OS X VI Editor BSD Linux
  • 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: 7647
522
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch!
 
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: 7647
522
Mac OS X VI Editor BSD Linux
  • 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
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • 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: 130
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: 130
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.
 
author
Posts: 23878
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux 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: 7647
522
Mac OS X VI Editor BSD Linux
  • 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: 130
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.
 
I was born with webbed fish toes. This tiny ad is my only friend:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic