Discussion in 'Object Oriented Concepts' started by vbraojava, Sep 8, 2008.
-Default size of Reference Variable is 8 bytes.
-Default value is NULL
size of refference variable is 4 byte becoz reffernce variable always of int type by default.
A refference variable is a local variable so it must be initalized by some value or obect.
that mean's it i not reffering to any object....
In my opinion Reference variable default size is 8 bytes. Ok we consider your answer that is "referenced variable default size is 4 bytes and its type is int" as correct, then it is not possible to assign a null value to the int variable
Am I right or not? I am also not sure about it, so plz once check with your answer and justify your answer.
The default size of a reference variable depends on the type of reference variable
I think Above answers are wrong i agree with mr. balu. The default size of ref of the varibale is depend on the type of type of variable, becoz we can create ref variable to int, float, String, Class, Interface, etc.
I dont think so that size of reference variable is depand on the type, if yes then what about if the return type is a "class" type, how many it takes now???
any one can tell size of reference variable is depand on the type or not
Reference variable size is depands on the type of JVM...
can i have specific ans...
how and why
Size of a reference variable can never depend on the type of value it points to. In any case it always stores an address.
Now the bytes reqd to store that address might depend upon the JVM (um not sure)
default size of Reference Variable is number of bytes req'd to store address..
hi I am gaurav I have consulted with books and i found that refernce variables are local variable just like as ponter in c/c++ and as we know that local variable lies on stack so they must be initalized with some value otherwise we will get compile time error so we can initalize referce variable only null or Object. Am I right
woo woo wooo hold on guys !! wat are u guys thinking...dont think complex...its simple.....size of reference variable is INDEPENDENT of the data type....
and its size is 4bytes as some one sed above !!
and its value is null default...
hello dear friend size of reference variable by default is 8 byte.
hello dear friend size of reference variable by default is 8 byte, dear friend its right that it has integer means its like address as pointer in c/ c++.
hi friends i am reading all answer regarding question.
i want to give an example
above is class declaration and then we declare refrence variable
a o; <---- This is reference variable
a o=new a();<-----This is creating an object so here o is the object (a reference variable which hold address of an object)
So,if we only declare refrence variable then its value is null it means no size.
and if we declare as a second type then the value is a address which is a hexa decimal value
as we knw while creating the object we use "new " operator it returns the addr of the memory location and this adrr is going into store inside the reference variable thats y it should depend on the jvm not on the type of the variable..........
ooF.. what is the correct answer of these
am totally confusing , can anybody give me proof(Book) for size of reference varaible please
thanks in advance
Sorry for late reply.
Actually in my opinion refference variable(a special variable that reffers object) is much simillar with pointers in C,there are lot's of diffrences too.But in case of size both of them have simillarity both of them have int type so in case of C-language pointer type is 2 byte and in case of java we have 4byte size.I agree it, default value is null. and it's a local variable that means it lies on stack it must be initalized by null or some object refference.
I dont think so.Because java doesn't have any size of operator to find size . we cant justify it is 8 bytes
Separate names with a comma.