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
What are decalarations?
What do you mean by local class?
What is an empty list in java?
How do you reverse sort a list in java?
What is finalize method?
Which collection is thread safe in java?
What is derived datatype?
Does it matter in what order catch statements for filenotfoundexception and ioexception are written?
What do you mean by data type?
Can you access the private method from outside the class?
Can we inherit a class with private constructor?
What is class??
What is a return in java?
Is an array a vector?
What is the meaning of variable in research?