Explain pass by reference and pass by value?
Answer Posted / ganesh nagalingam
***In Java, primitives and object references are passed by
value.***
The variable represents the bit information which is copied
to the parameter.
eg:primitive****
Say for primitives x=2, the value of 2 is represented in
bits and it is copied to the parameter variable.
eg:object reference***
Button b = new Button("hello");
Button c = b;
Similarly for object reference the bit value in the
reference is copied to the parameter reference. Thus both
references have the same value representing an object. The
object reference(bit representation) represents a way to
get to the object.
| Is This Answer Correct ? | 9 Yes | 1 No |
Post New Answer View All Answers
How do you sort a string in java?
Explain the difference between string, stringbuffer and stringbuilder in java?
How many characters is 2 bytes?
Explain the overview of UDP messaging.
how to prepare for IT Officers Interview in Banks
Define interface in java?
What are the different tags provided in jstl?
Why do you canvas?
Can arraylist contain null values?
What class allows you to read objects directly from a stream in java programming?
What is the dot operator?
What is a memory leak in java?
What is the main function in java?
What exactly is methodology?
Why is singleton not thread safe?