Does Java pass arguments by value or reference?

Answers were Sorted based on User's Feedback



Does Java pass arguments by value or reference?..

Answer / prs01

Pass by value.
1. When passing primitives, it passes a copy of the
variable to the method. Any change made in the method does
not reflect in the calling method.
2. When dealing with objects, a copy of their
reference/address is passed. Thus the change made to the
object is reflected in the calling method.

Is This Answer Correct ?    22 Yes 4 No

Does Java pass arguments by value or reference?..

Answer / sujini

java pass arguments only pass by value

Is This Answer Correct ?    4 Yes 1 No

Does Java pass arguments by value or reference?..

Answer / mr.h

In Java no matter what type of argument you
pass the corresponding parameter (primitive variable or object reference) will get a copy of that data, which is
exactly how pass-by-value (i.e. copy-by-value) work.

In Java, if a calling method passes a reference of an object as an argument to the called method then the passedin
reference gets copied first and then passed to the called method. Both the original reference that was
passed-in and the copied reference will be pointing to the same object. So no matter which reference you use, you
will be always modifying the same original object, which is how the pass-by-reference works as well

Is This Answer Correct ?    0 Yes 0 No

Does Java pass arguments by value or reference?..

Answer / roshni

yes by both

Is This Answer Correct ?    4 Yes 11 No

Does Java pass arguments by value or reference?..

Answer / vamsi krishna.i

Java Always takes arguments by reference Only.

Is This Answer Correct ?    0 Yes 7 No

Post New Answer

More Advanced Java Interview Questions

What is UniCastRemoteObject and what is its use in RMI?

6 Answers  


Wt is the main difference between Java and Java J2EE and Advanced java?

5 Answers   Wipro,


On a computer that having single CPU, how multithreading concept can be achieved?

1 Answers   Zensar,


what is container?

3 Answers   Infosys, Infotech,


What is the difference between session and entity beans?

0 Answers  


What is the difference between Super and This Keyword?

4 Answers   HCL, TCS,


How can a dead thread be restarted?

1 Answers   IBM, Wipro,


i have a 1000 objects in data base i need to display those in jsp's how can i retrive those objects in jsp. (consider the performance issue)

2 Answers  


hi, All are saying that now software field position is not good and in 5-10yrs total software field ll be saturated . is it true? i am unable decide ii continue in this field or not please tell me?

19 Answers  


advantage of thread?

3 Answers   HCL,


what is the use of State Factories?

0 Answers  


In RMI, inorder to sent the stub reference to the client, is we have to load the server object first into the memory or can we directly sent reference to the client?

0 Answers  


Categories