Does Java pass arguments by value or reference?
Answer Posted / 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 |
Post New Answer View All Answers
What is meant by method chaining?
To identify IDL language what mapping mechanism is used?
Difference between DurableSubscription and non- DurableSubscription?
What is a modular application?
Write a program to show synchronization?
What are local interfaces? Describe.
How would you detect a keypress in a jcombobox?
What is the difference between ear, jar and war file?
What are the different class loaders used by jvm?
Why are my checkboxes not being set from on to off?
How a component can be placed on Windows?
What is the highest-level event class of the event-delegation model?
what are the activation groupworks?
What restrictions are placed on the location of a package statement within a source code file?
What is the difference between the string and stringbuffer classes?