aspose file tools*
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
Author

Need help for Marcus exam No1 #58

kevin jia
Ranch Hand

Joined: Jul 13, 2000
Posts: 38
Hi,
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
//Base.java
package Base;
class Base{
protected void amethod(){
System.out.println("amethod");
}//End of amethod
}//End of class base
package Class1;
//Class1.java
public class Class1 extends Base{
public static void main(String argv[]){
Base b = new Base();
b.amethod();
}//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!!!
jafarali
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
Hi,
Thanks jafarali for your help.
Marcus Green
arch rival
Rancher

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.
Marcus

SCWCD: Online Course, 50,000+ words and 200+ questions
http://www.examulator.com/moodle/course/view.php?id=5&topic=all
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help for Marcus exam No1 #58