Java Reference
In-Depth Information
Review Questions
1. The following code appears in a file named Plant.java. What is the result of compiling
this source file? (Select one answer.)
1. public class Plant {
2. public boolean flowering;
3. public Leaf [] leaves;
4. }
5.
6. class Leaf {
7. public String color;
8. public int length;
9. }
A. The code compiles successfully and two bytecode files are generated: Plant.class and
Leaf.class
B. The code compiles successfully and one bytecode file is generated: Plant.class.
C. A compiler error occurs on line 1.
D. A compiler error occurs on line 3.
E. A compiler error occurs on line 6.
2. Suppose a class named com.mycompany.Main is a Java application, and Main.class is in
the following directory:
\projects\build\com\mycompany
Which of the following commands successfully executes Main? (Select two answers.)
A. java -classpath=\projects\build com.mycompany.Main
B. java -classpath \projects\build\com\mycompany Main
C. java -classpath \projects\build com.mycompany.Main
D. java -classpath \projects\build\com mycompany.Main
E. java -cp \projects\build com.mycompany.Main
3. A class named Test is in the a.b.c package, defined in a file named Test.java and saved
in the following directory:
c:\abcproject\src\Test.java
Assuming the code in Test.java uses only classes from java.lang and contains no com-
piler errors, what is the result of the following command line? (Select one answer).
c:\abcproject\src>javac -d c:\abcproject\deploy Test.java
Search WWH ::




Custom Search