Monday, September 21, 2009

Java Object Reference Variables

How Big Is a Reference Variable?

You don't know.Only the people who involved in the development of Java JVM knows it.But, all the references for a given JVM will be of same in size regardless of the objects they reference, but each JVM might have a different way of representing references, so references on one JVM may be smaller or larger than references on other JVM. So, the size of the object references are the same size, regardless of the size of the actual objects that they refers to. But java not permitting us to know complete details like size of the Object reference variables. These variables acts as a pointers to point to the objects. And Java wont allow us to perform arithmetic or any other type of operations on object variables.

An object reference variable holds bits that represents the way to access a particular object. It doesnt hold the complete object, but it holds something like a pointer.And an object reference variable represents only one object....


What will be the initial value of an object reference which is defined as an instance variable?



The object references are all initialized to null in Java. However in order to do anything useful with these references, you must set them to a valid object, else you will get NullPointerExceptions everywhere you try to use such default initialized references.

No comments:

Post a Comment

 

Onion Labs © 2008 ---- Sakshieducation, Onion Labs.