• +91 9723535972
  • info@interviewmaterial.com

Java Interview Questions and Answers

Question - What is NullPointerException and how to handle it?

Answer - When an object is not initialized, the default value is null. When the following things happen, the NullPointerException is thrown: --Calling the instance method of a null object. --Accessing or modifying the field of a null object. --Taking the length of a null as if it were an array. --Accessing or modifying the slots of null as if it were an array. --Throwing null as if it were a Throwable value. The NullPointerException is a runtime exception. The best practice is to catch such exception even if it is not required by language design.

Comment(S)

Show all Coment

Leave a Comment




NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners