June 2005
Beginner to intermediate
312 pages
6h 24m
English
This chapter contains puzzlers that concern the use of classes and their instances, methods, and fields.
This puzzle presents you with two Confusing constructors. The main method invokes a constructor, but which one? The program’s output depends on the answer. What does the program print, or is it even legal?
public class Confusing { private Confusing(Object o) { System.out.println("Object"); } private Confusing(double[ ] dArray) { System.out.println("double array"); } public static void main(String[ ] args) { new Confusing(null); }}
The parameter passed to the constructor is the ...