• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Confusion in understanding question for OCA IZO 808 Guide book (Sybex)

 
Greenhorn
Posts: 8
1
Tomcat Server Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was going through the book 'OCA Oracle Certified Associate Java SE 8 Programmer I Study Guide Exam 1Z0-808' for OCA preparation. In the review questions for 1st Chapter I have a confusion in understanding the way the question is presented.  I am posting the question below as it is. From the question I am unable to make out, whether all the classes mentioned here , are present in the same file or not. If we consider all of the classes to be in one java file, then the answer should be option F. But thats not the case, according to the answers given later.  Can someone help me understand where my understanding of question went wrong.



5. Given the following classes, which of the following can independently replace INSERT
IMPORTS HERE to make the code compile? (Choose all that apply)



A. import aquarium.*;
B. import aquarium.*.Jelly;
C. import aquarium.jellies.Jelly;
D. import aquarium.jellies.*;
E. import aquarium.jellies.Jelly.*;
F. None of these can make the code compile.


 
author & internet detective
Posts: 39343
755
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch! I added "Sybex" to your subject. In the future, please mention the publisher as a number of books have similar titles.

It is safe to assume that package statements (or imports) start a new file.
 
Maxitoxin Mayank
Greenhorn
Posts: 8
1
Tomcat Server Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jeanne Boyarsky wrote:Welcome to CodeRanch! I added "Sybex" to your subject. In the future, please mention the publisher as a number of books have similar titles.



Thanks for the edit in my post and the answer


It is safe to assume that package statements (or imports) start a new file.

I was further searching on this and came up with the below explanation.
If all the statements above are in one file, it won't compile if the order is same. Import statements can not occur after a class declaration.
Correct me if I am wrong.
.  
 
Jeanne Boyarsky
author & internet detective
Posts: 39343
755
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Maxitoxin Mayank wrote:I was further searching on this and came up with the below explanation.
If all the statements above are in one file, it won't compile if the order is same. Import statements can not occur after a class declaration.
Correct me if I am wrong.
.  


Right! Unless the question is specifically asking about the order of elements, you can assume package/import starts a new file.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!