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

Java Questions Object References: You use a null reference to indicate that

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!