File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Cant think of one:-)" Watch "Cant think of one:-)" New topic
Author

Cant think of one:-)

Suresh Chidambaram
Greenhorn

Joined: Aug 05, 2000
Posts: 20
Dont remember from where - most prolly marcus green exam 2:
//File P1.java
package MyPackage;
class P1{
void afancymethod(){
System.out.println("What a fancy method");
}
}
//File P2.java
public class P2 extends P1{
afancymethod();
}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 P1.java is the equivalent of placing the file in a different directory to the file P2.java 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 P1.java is the equivalent of placing the file in a different directory to the file P2.java"
Does this mean that one doesnt actually need to place P1.java 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: http://aspose.com/file-tools
 
subject: Cant think of one:-)