+ 3

What is Null pointer expections in Java

#1 Question

16th Oct 2021, 7:21 AM
ASHUTOSH CHAUDHARY
ASHUTOSH CHAUDHARY - avatar
6 Respuestas
+ 2
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
16th Oct 2021, 8:41 AM
zemiak
+ 2
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
17th Oct 2021, 4:33 PM
sree harsha
sree harsha - avatar
+ 1
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
16th Oct 2021, 2:03 PM
Adithya Keshav T
Adithya Keshav T - avatar
+ 1
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
17th Oct 2021, 3:01 PM
sree harsha
sree harsha - avatar
+ 1
sree harsha NullPointer is an runtime exception. Runtime errors are different from runtime exceptions.
17th Oct 2021, 3:09 PM
Adithya Keshav T
Adithya Keshav T - avatar