What is Null pointer expections in Java | Sololearn: Learn to code for FREE!


What is Null pointer expections in Java

#1 Question

10/16/2021 7:21:23 AM


6 Answers

New Answer




if variable for some object is null it means is empty you can't call any method of object in variable, because there is not any object Object o = null; o.hashCode(); //NullPointerException


Adithya Keshav T Exception definition is it is a runtime error It is basic definition Exception is a kind of error that can be handled but not rectified


NullPointerException is a runtime exception and it is thrown when we try to use an object reference which has a null value. Ex: https://code.sololearn.com/cWW2MY3wT22u/?ref=app


NullPointerException is a type of runtime error The object that we are either created or in usage is not having memory Ex : Student - class It is having method wish(); I am doing this Student s; s.wish(); The above 2 statements will raise java.lang.NullPointerException Since the value of s is null by default


sree harsha NullPointer is an runtime exception. Runtime errors are different from runtime exceptions.