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


Please Help Members By Posting Answers For Below Questions

What do you understand by abstract classes?

826


What is a marker interface?

818


How is abstraction implemented in java ?

727


How do I stop concurrentmodificationexception?

735


What is var keyword ?

925


Which class contains a method: cloneable or object?

763


What is difference between float and double?

697


What are aggregate functions explain with examples?

785


Define how does a try statement determine which catch clause should be used to handle an exception?

807


How to print nodes of a Binary tree?

2002


How many types of equations are there?

750


What is difference between path and classpath in java?

702


What happens to a static var that is defined within a method of a class?

775


How would you use Bubble Sort to sort the number of elements?

815


What is %d in printf?

750