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

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

 
Greenhorn
Posts: 8
1
Java Linux Tomcat Server
  • 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: 39283
727
Eclipse IDE Java VI Editor
  • 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
Java Linux Tomcat Server
  • 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: 39283
727
Eclipse IDE Java VI Editor
  • 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.
 
Trust God, but always tether your camel... to this tiny ad.
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!