Java Reference
In-Depth Information
< Day Day Up >
Puzzle 93: Class Warfare
This puzzle tests your knowledge of binary compatibility : What happens to the behavior of one
class when you change another class on which the first class depends? More specifically, suppose
that you compile the following two classes. The first is meant to represent a client; the second, a
library class:
public class PrintWords {
public static void main(String[] args) {
System.out.println(Words.FIRST + " " +
Words.SECOND + " " +
Words.THIRD);
}
}
public class Words {
private Words() { }; // Uninstantiable
public static final String FIRST = "the";
public static final String SECOND = null;
public static final String THIRD = "set";
}
Now suppose that you modify the library class as follows and recompile it but not the client
program:
public class Words {
 
 
Search WWH ::




Custom Search