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

Differentiate jar and war files?

578


What does arrays sort do in java?

529


How many bits is a word?

551


What is byte code and why is it important to java’s use for internet programming?

584


How to connect to a remote database using Applet?

2036






What is the basic concepts of OOPS?

677


What is linkedlist in java?

493


what is the purpose of using rmisecuritymanager in rmi?

556


What are access specifiers available in java?

569


What is the static field modifier?

586


Does java allow default arguments?

586


How do you trim a space in java?

489


What are the data types supported by java?

540


What is difference between Heap and Stack Memory?

523


What is the meaning of I ++ in java?

593