I'm pretty sure that in the real exam you won't see a question like the one you drafted, where package access makes a difference, that fails to tell you the package relationship between the classes. You might see it in practice exams, but you shouldn't see it in the real thing. That said, I don't have the questions here in front of me, so I can't state that with absolute certainty.
Suresh Regmi wrote:I am little confused with this kinds of questions, do I assume they are in same package? different package? Your suggestion is appreciated.
K&B7, Question Format, Multiple-Choice Questions wrote:The real exam typically numbers lines of code in a question. Sometimes we do not number lines of code—mostly so that we have the space to add comments at key places. On the real exam, when a code listing starts with line 1, it means that you're looking at an entire source file. If a code listing starts at a line number greater than 1, that means you're looking at a partial source file. When looking at a partial source file, assume that the code you can't see is correct. (For instance, unless explicitly stated, you can assume that a partial source file will have the correct import and package statements.)
Furthermore, if they want to test your knowledge about packages and access modifiers for example, the questions on the real exam will clearly mention the different packages (and source files). So if you see a code snippet like that, you can assume that all classes are in the same source file (and thus package).
Here is some very important advice: NEVER assume something which is not mentioned in the question. So if class A, B, and C would be in a seperate package, that will definitely be mentioned in the question!
Hope it helps!
Options that need to refer to a line of code will then refer to the line of code like this: Compilation failure at //line 1.
This is the format we have been following in our questions as well (because it is easy for a reader to just copy paste the code into their java file and compile/execute it).
2. You will see a lot of code in real exam that omits a lot of details such as package and import. Many are just code fragments without any wrapping method or a class. Again, no line numbers. You just have to assume that all information that is not provide does not affect the answer. In the code that you mentioned above, there is no package statement, that means all the code belongs to the default package. No need to assume anything here. Most of the time it is just common sense. You will easily figure that out as you attempt more and more questions.
Paul Anilprem wrote:1. The information given above about real exam questions typically containing line numbers is obsolete. They followed this format earlier but they do not anymore. We have seen that most of the questions in fact do not contain any line numbers.
That's good to know! I have to admit, I took the OAJP7 exam only 6 months ago and can't remember this one.
Paul Anilprem wrote:2. You will see a lot of code in real exam that omits a lot of details such as package and import. Many are just code fragments without any wrapping method or a class. Again, no line numbers. You just have to assume that all information that is not provide does not affect the answer.
I do remember this one from the OCAJP7 exam. It makes the code evaluation part a bit easier because you have to assess less code to see if the code compiles or not.
I didn't see any questions where the only problem was a missing import anyway. Besides you do get a random subset of the questions, so I wasn't comfortable saying that it never happens.