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 a constructor call the constructor of parent class?
what is singleton in java?
What are the rules for naming an array?
Can main() method in java can return any data?
Difference between a process and a program?
Variables used in a switch statement can be used with which datatypes?
What is the length of a string?
How many bits are used to represent unicode, ascii, utf-16, and utf-8 characters in java programming?
What is default exception handling in java?
How many bytes is double?
Do loops java?
What is an example of procedure?
How we can skip finally block of exception even if some exception occurs in the exception block in java?
Can we make main() thread as daemon?
What are the 8 primitive data types in java?