Question: Java Questions Object References: You use a null reference to indicate that an object variable (reference) does not refer to any object. Of course, you
Java Questions

Object References: You use a null reference to indicate that an object variable (reference) does not refer to any object. Of course, you cannot invoke methods on a null reference since there is no object to which the method would apply. Consider this program segment: String str null; System.out.println (str) str.length) System.out.println (str) 1. What problem arises when executing these statements? Do the statements produce any printout beyond an error message? If so, what printout? (2 points) 2. Explain why it would be a poor decision to make instance data public instead of private. Give an example of why this could result in a problem. (2 points)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
