Search Interview Questions | More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know. |
|
| ||||
Interview Questions and Answers | ||||
| ||||
Ans. We can declare the reference as final to avoid reassignment but again we can always initialize the final reference to null. Even if there was any such facility available , it would have meant poor use of resources by assigning a new object in memory to each reference that's created. Many a times references are just meant to refer to other objects which already have a reference i.e sharing object by multiple references. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  null  NullPointerException | ||||
Related Questions | ||||
When does an application throw NullPointerException ? | ||||
Which of the following exception is thrown when we try to access element which is beyond the size ? | ||||
Is it ok to use optional everywhere just to get over nullpointerexception ? | ||||
How would you go about debugging a NullPointerException? | ||||
How can we protect an application from throwing a NullPointerException ? | ||||
Invoking start twice on same thread leads to .. | ||||
Is it a bad practice to initialize object reference to Null ? | ||||