jQuery in Action, 3rd edition
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Need help for Marcus exam No1 #58 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Need help for Marcus exam No1 #58" Watch "Need help for Marcus exam No1 #58" New topic

Need help for Marcus exam No1 #58

kevin jia
Ranch Hand

Joined: Jul 13, 2000
Posts: 38
Could anyone tell me what the Marcus wants to say on this question.
You have these files in the same directory. What will happen when you attempt to compile and run Class1.java if you have not already compiled Base.java
package Base;
class Base{
protected void amethod(){
}//End of amethod
}//End of class base
package Class1;
public class Class1 extends Base{
public static void main(String argv[]){
Base b = new Base();
}//End of main
}//End of Class1
1) Compile Error: Methods in Base not found
2) Compile Error: Unable to access protected method in base class
3) Compilation followed by the output "amethod"
4)Compile error: Superclass Class1.Base of class Class1.Class1 not found
The answer is 4), but what it wants to say , I don't understand,I completely lost.
Need your help!!!
Ranch Hand

Joined: Jul 15, 2000
Posts: 37
Class Base is a member of package Base and Class1 is a member of package Class1.
Class Base have only package access so we will not be able to access from another package.
Eventhough you make it 'public' you have mention 'Base.Base' instead of just mentioning 'Base'
kevin jia
Ranch Hand

Joined: Jul 13, 2000
Posts: 38
Thanks jafarali for your help.
Marcus Green
arch rival

Joined: Sep 14, 1999
Posts: 2813
The answer text given on that page is as follows
"Using the package statement has an effect similar to placing a source file into a different directory. Because the files are in different packages they cannot see each other. The stuff about File1 not having been compiled was just to mislead, java has the equivalent of an "automake", whereby if it was not for the package statements the other file would have been automatically compiled. "
Should I attempt to re-phrase it to make it more clear? Suggested words are very welcome.

SCWCD: Online Course, 50,000+ words and 200+ questions
I agree. Here's the link: http://aspose.com/file-tools
subject: Need help for Marcus exam No1 #58
It's not a secret anymore!