aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Cant think of one:-) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Cant think of one:-)" Watch "Cant think of one:-)" New topic

Cant think of one:-)

Suresh Chidambaram

Joined: Aug 05, 2000
Posts: 20
Dont remember from where - most prolly marcus green exam 2:
package MyPackage;
class P1{
void afancymethod(){
System.out.println("What a fancy method");
public class P2 extends P1{
}1) Both compile and P2 outputs "What a fancy method" when run
2) Neither will compile
3) Both compile but P2 has an error at run time
4) P1 compiles cleanly but P2 has an error at compile time
Answer to Question 9: 4.
"The package statement in is the equivalent of placing the file in a different directory to the file and thus when the compiler tries to compile P2 an error occurs indicating that superclass P1 cannot be found."
No problem with the answer but the explanation beats me. Firstly, the whole question is ambigous. One must assume the directory being talked about is one named MyPackage and whose parent directory is in the classpath. Otherwise, ofcourse, P1 wouldnt compile.
"The package statement in is the equivalent of placing the file in a different directory to the file"
Does this mean that one doesnt actually need to place in a directory called X/MyPackage where X is a directory in the classpath?Merely putting a package statement would simulate the effect??
No problem with the final answer, though!!

Romba Chinna Thambi
I agree. Here's the link:
subject: Cant think of one:-)
Similar Threads
package directory
Marcus Green - Exam 2 - Question 9
Marcus Green's mock up test questions
Package visibility