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
Can java program run without jre?
Why char array is favored over string for the storage of passwords?
What is finalize method?
How to create a thread in java?
What is the difference between a vector & an array list?
What are the limitations of procedural programming approach?
What is class??
What is a boolean structure?
Explain an intermediate language?
What is the driver class?
How do you get length in java?
Name and explain the types of ways which are used to pass arguments in any function in java.
What is the use of object and class classes?
What is difference between classpath and path variables in java?
What is a map in java?