• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Chapter 1 Review Question #14 (Java OCA 8 Programmer I Study Guide, Sybex)

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am currently reading the OCA Java SE 8 Programmer I Study guide of Boyarsky and Selikoff and I have a question about the solution of review question #14 of chapter 1.


I don't understand why the only valid response is D.

For example if I replace "INSERT CODE HERE" by package my.directory.name.A;
and I launch the command : javac ./named./A/Bird.java. I have no compilation error.

Could you help me to understand my error ?

 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi christophe Leconte,

First of all, a warm welcome to CodeRanch!

christophe Leconte wrote:I don't understand why the only valid response is D.

For example if I replace "INSERT CODE HERE" by package my.directory.name.A;
and I launch the command : javac ./named./A/Bird.java. I have no compilation error.


Strictly speaking you are correct: you can insert any of those package statements and the code will compile successfully. But the question is clearly testing your knowledge about package statements. So from the naming of the current directory (/my/directory), you should know that my.directory can't be a part of the package statement (and therefore B can't be a correct answer).
In such a question it's very important to be aware of the "context of a question". This question only has answer options with package statements and in the question itself the directories where the Java source code file resides and from where the source code file will be compiled is the same, so it's clearly about choosing the most appropriate answer. In this thread you'll find a nice discussion about this "context of a question", it's definitely worth reading.
In this topic you'll find a discussion about exactly the same review question.

Hope it helps!
Kind regards,
Roel
 
christophe Leconte
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your response, I will try to keep in mind the context of the question.

Best regards.

Christophe.
 
Oh. Hi guys! Look at this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic