Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Question about the OCA exam  RSS feed

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I saw this question from OCA/OCP Java SE 7 Programmer I & II Study Guide by Kathy Sierra



Until now, All the questions I've seen this kind clearly note that every class in A separate file.
I thought that there is a compile time error because two public classes in the same file and also two package statements.

Oracle exam topics wrote:No file or directory path names for classes: If a question does not state the file names or directory locations of classes, then assume one of the following, whichever will enable the code to compile and run:
All classes are in one file
Each class is contained in a separate file, and all files are in one directory



there are such questions like this?
thanks
 
Ranch Hand
Posts: 47
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Maor;)

I think this questions intend is not about someone
realizing if the classes are in the same file or not.
I think they have put the code in one section so
you can just see both classes and packages here.

I think the possible answers are B. and C.

But I think a more experienced programmer
should clarify this, as I am new to the Code
Ranch myself.

Kind regards
Florian
 
Enthuware Software Support
Ranch Foreman
Posts: 4132
34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Maor Pau wrote:

Oracle exam topics wrote:No file or directory path names for classes: If a question does not state the file names or directory locations of classes, then assume one of the following, whichever will enable the code to compile and run:
All classes are in one file
Each class is contained in a separate file, and all files are in one directory



The statement that you've quoted from Oracle makes it clear that you should assume the two classes to be defined in separate files. So not sure what is the issue.
 
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

Maor Pau wrote:I thought that there is a compile time error because two public classes in the same file and also two package statements.


This topic covers the same question and exactly the same doubt as you have. So it's definitely worth reading!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!