|
What is reference variable c initialized to? A good answer might be:
| |
Testing for nullA String object that contains no characters is still an object. It is similar to having a blank sheet of paper, versus having no paper at all. Overlooking this distinction is one of the classic confusions of computer programming. It will happen to you. It still happens to me. To prepare for future confusion, study the program, step-by-step:
The System.out.println() method expects a reference to a String object as a parameter. The example program tests that each variable contains a String reference before calling println() with it. (Actually, println() will not crash if it gets a null. But some methods will. Usually you should insure that methods get the data they expect). | |
QUESTION 4:Examine the following code snippet: String alpha = "Dempster Dumpster"; alpha = null;
|