Javatpoint Logo

Regarding java exception

By: bcepre*** On: Sat Jan 28 01:15:50 IST 2017     Question Reputation0 Answer Reputation0 Quiz Belt Series Points0  0Blank User
when java does not support pointer why there is a nullpointer ExceptionUp0Down
core java  x  328Tags

 
Yes, in java, there is no pointers(*). But Reference variable has taken their place.

Reference variable holds the address of an object.

Student s = new Student(); // s is pointing to an object.

NullPointerException exception comes , when that reference variable has 'null' as its value (i.e. not pointing to any object) and still trying to call a member of a class.
Image Created0Down

By: [email protected] On: Sat Jan 28 13:49:50 IST 2017 Question Reputation0 Answer Reputation0 Belt Series Points0 0User Image
Are You Satisfied :0Yes0No
 
Yes, in java, there is no pointers(*). But Reference variable has taken their place.

Reference variable holds the address of an object.

Student s = new Student(); // s is pointing to an object.

NullPointerException exception comes , when that reference variable has 'null' as its value (i.e. not pointing to any object) and trying to call a members of a class.
Image Created0Down

By: [email protected] On: Sat Jan 28 14:11:58 IST 2017 Question Reputation0 Answer Reputation0 Belt Series Points0 0User Image
Are You Satisfied :0Yes0No
 
Image Created0Down

By: [email protected] On: Sun Jan 29 02:30:43 IST 2017 Question Reputation0 Answer Reputation0 Belt Series Points0 0User Image
Are You Satisfied :0Yes0No
 
hjjhImage Created0Down

By: [email protected] On: Fri Feb 17 16:14:44 IST 2017 Question Reputation0 Answer Reputation0 Belt Series Points0 0User Image
Are You Satisfied :0Yes0No