Java OCA OCP Practice Question 3040

Question

Given:

2. import rt.utils.Remote;  
3. public class Main{  
4.   public static void main(String[] args){  
5.     Remote remote = new Remote();  
6. }  } 

And rt.utils.Remote class is properly bundled into a JAR file called my.jar.

And given the following steps:

P.  Place my.jar in the  $ROOT directory.
Q.   Extract my.jar and put rt directory with its subdirectories in the  $ROOT directory.
R.  Extract my.jar and place Remote.class in the  $ROOT directory.
S.   Place my.jar in the  $JAVA_HOME/jre/lib/ext directory.
X.   Compile using: javac -cp my.jar Main.java
Y.   Compile using: javac Main.java
Z.   Compile using: javac -cp . Main.java

If Main.java resides in the $ROOT directory, which set(s) of steps will compile the Main class? (Choose all that apply.)

  • A. P -> X
  • B. Q -> Y
  • C. R -> Z
  • D. P -> Z
  • E. R -> Y
  • F. S -> X
  • G. S -> Z


A, B, F and G are correct.

Note

When the JAR is placed in any directory other than $JAVA_HOME/jre/lib/ext directory, it should be included in the classpath.

If the JAR file is in the $JAVA_HOME/jre/lib/ext directory, it's NOT necessary to include the JAR in the classpath.

If the JAR file is extracted, the complete directory structure should exist on the classpath.




PreviousNext

Related