Term
Where are the two places that the java and javac commands look for other classes, and which one takes precedence? |
|
Definition
1) In the directories that come standard with J2SE 2) In the directories defined by the classpaths (1 occurs before 2) (p. 797) |
|
|
Term
Where are the two places a classpath can be declared, and which takes precedence? |
|
Definition
1) As an operating system environment variable (used by default) 2) As a command-line option (overrides any classpath declared as an environment variable only for the invocation) (p. 797) |
|
|
Term
T/F: When you specify a directory on a classpath, you're also specifying the directories leading to that directory (e.g. -classpath /com/foo/acct will look in com, foo, and acct) |
|
Definition
F: Only acct will be searched with the sample classpath (p. 797) |
|
|
Term
T/F: When searching for class files, java and javac search the current directory by default. |
|
Definition
F - You must tell them to search there by using a dot (.) in your classpath (p. 798) |
|
|
Term
T/F: When you're telling javac which .java file to compile, javac looks in the current directory by default. |
|
Definition
|
|
Term
In what order are classpaths searched? And what happens duplicate classes are found? |
|
Definition
The classpath is searched rom left to right, and the first matching class file found will be the one that is used. (p. 797/798) |
|
|
Term
Which command guarantees that you can abbreviate the -classpath option as -cp: java or javac? |
|
Definition
java The -cp abbreviation may or may not work with javac (p. 798) |
|
|
Term
Given the following: package com.foo; public class MyClass { }
What is its fully qualified name? |
|
Definition
|
|
Term
It is legal to use an alias when invoking a java class on the command line (i.e. invoking java MyClass when MyClass is declared with a package com.foo statement) |
|
Definition
F: A class name is atomic and can never be split up on the command line or in an import statement. (Within the code, the class may be using an alias (via the import statement), but that is always referring back to the fully qualified name in the import statement) (p. 799) |
|
|
Term
T/F
When using a wildcard such as a * i.e.
import java.util.* you are saying to use the short name for all classes in the java.util package.
When invoking java.util.* you get all of the jar classes and subpackages within the util package. |
|
Definition
T
F - you get only classes with the java.util package.
pg 805 |
|
|
Term
Does the following code compile?
import java.lang.System.out;
import java.lang.Integer.*;
public class TestImports
static public void main(String arg[]) {
out.println(MAX_VALUE);
out.println(toHexString(42));
}
} |
|
Definition
No, you need to "import statics"
(or use static imports if you prefer)
import statics are defined as
import static java.lang.System.out
import static java.lang.Integer.*
pg806 |
|
|
Term
Public class Arg{
public static void main(String[] args) {
int x = 0;
for (String s: args)
System.out.println(x++ + " element = " + s);
}
}
Which of the following are proper statements to add command line arguments?
A. java Arg x 1
B. java Arg (x,1)
C. java Arg 1 1
D. java Arg(x,1)
E. java Arg(1,1) |
|
Definition
|
|
Term
Which are valid main method declarations?
A. static public void main(String[] args)
B. public static void main(String... x)
C. static public void main(String stuff[]) |
|
Definition
|
|
Term
Given TestProps is a functional application:
java -DpropA=test TestProps
will create a property called DpropA with value "test". True or False?
|
|
Definition
False.
will create propA with "test" |
|
|
Term
package com; import com.pizza.Toppings; class PizzaClass { void preparePizza() { Toppings toppings = new Toppings(); com.pizza.Dough d = new com.pizza.Dough(); d.add(toppings.getCheese()); d.add(toppings.getPepproni()); } }
Given that PizzaClass compiles, what class files will be located in the pizza subdirectory?
|
|
Definition
Toppings.class and Dough.class (pg800) |
|
|
Term
Given that a user can navigate to the following directory: /dirA/dirB/dirC
If the user is in dirB, which directories will be searched given the following classpath? -cp dirA:dirB/dirC:dirA/dirB |
|
Definition
None. These are all relative class paths. No directories will be found.(pg801) |
|
|
Term
What does the -d option of the javac command do? |
|
Definition
Specifies directory to place the generated .class files
pg 791 |
|
|