Q. Do instance variables have default initial values that we can depend upon?
A. Yes. They are automatically set to
0 for numeric types,
false for the boolean type, and the special value
null for all reference types. These values are consistent with the way Java automatically initializes array elements. This automatic initialization ensures that every instance variable always stores a legal (but not necessarily meaningful) value. Writing code that depends on these values is controversial: some experienced programmers embrace the idea because the resulting code can be very compact; others avoid it because the code is opaque to someone who does not know the rules.
Q. What is
A. It is a literal value that refers to no object. Using the ...