Java Reference
In-Depth Information
Review Questions
1.
What are the two basic purposes of packages?
2.
If you do not declare a class in a package, the class is in the __________________
package.
Use the following A and B class definitions to answer the ensuing five questions:
//filename A.java
package a;
public class A
{
private int x;
public int y;
protected int z;
double d;
public A()
{
}
}
//filename B.java
package b;
import a.A;
public class B extends A
{
private byte s;
public byte t;
public B()
{
}
}
3.
Which variables are accessible within the constructor of the B class?
4.
Suppose that a class, C, is declared in a package named c. Which variables in A and B
will C have access to?
5.
In what directory does A.class need to appear? In what directory does B.class need to
appear?
6.
What are the fully qualified names of the A and B classes?
7.
Suppose that A.class is in a directory named c:\code\review\a\. What directory should
appear in the CLASSPATH environment variable so that the A class can be found in the
classpath?
8.
What package never needs to be explicitly imported?
9.
Hiding the fields of a class by making them private is referred to as ______________.
10.
True or False: If a class has a static field, the field cannot be accessed until at least one
instance of the class is created in memory.
Search WWH ::




Custom Search