Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

Java is not supporting pointer, then why jvm is throwing null pointer exception?

user-image
Question added by Mohd shahnawaz khan , Associate Project , Cognizant Technology Solution
Date Posted: 2013/08/21

java does indeed have pointers.They can have two kinds of values-1)refrences to objects2)null  This is a language used in specification.

Daanish Rumani
by Daanish Rumani , Product Manager , Publicis Sapient

It is a badly named exception perhaps due to its C++ roots.
Interestingly C# calls the corresponding exception as NullReferenceException. 

Gopal kulkarni
by Gopal kulkarni , NexGen , nexgen

java support pointer internally.

Faisal Alghamdi
by Faisal Alghamdi , Senior IT Supervisor , al-nahdi medical company saudi arabia

Definitely there are pointers in Java and the null pointer error is one of them but they are managed by the JVM.
However, you are not required to deal with them "directly" as you do with C++.
You create refrences by delclaring new variables..
They are pointers.
When you declare a variable "pointer" then you need to initialize before using this variable..
otheriwse you will get an error.

mukhtar ahmed Ibrahim
by mukhtar ahmed Ibrahim , Software engineer , Norwegian tax administration

We don't use pointers in java. But internal implementation of JVM uses pointers.  When you allocate memory for an object by calling new, you get back a pointer. 

Java as any java developer knows doesnt support pointers like c++ , however as u know the JVM supports reference, and references point to objects' places in the virtual machine's memory.so as a conclusion its a badly-named exception and probably got its name as a heritage from C.
 

Advaitha Chidurala
by Advaitha Chidurala , Teacher , Little Masters Abacus

Pointers are generally used to refer to the address of the particular value. there is nowhere the concept of pointers in Java. Null pointer exception is generally raised when you are try to perform some actions with the keyword "null".

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.