Hi guys,
Is someone doing these exams?
I the second full practice exam, question 21, page 204, the correct answers are D and F, but the answer F is not correct:
"When javac is invoked with a classpath option, and you need to find files in a JAR file, the name of the JAR file must be included at the end of the path."
I tried with this example:
---------------------------------------------
File A.java
public class A extends B {
static { System.out.println("A"); }
public static void main(
String... args) {
System.out.println("main");
}
}
class B extends C {}
class C {}
---------------------------------------------
Current directory: temp
I compiled A.java and delete A.class, move B.class to dirB, create C.jar with C.class inside and move the C.jar to dirC, then delete C.class en temp
Final directory structure:
/temp
|---- A.java
|---- dirB
|---- B.class
|---- dirC
|---- C.jar
I tried this:
$javac -cp dirC/C.jar:dirB A.java
And the fila A.class is generated in /temp
Then, I tried:
$java -cp dirC/C.jar:dirB:. A
And the output was:
A
main
This means that the file C.jar does not need to be at the end of the path in the -cp option
Can anyone confirm me that F is not a correct answer?
Thanks in advance,
Alvaro