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


Please Help Members By Posting Answers For Below Questions

Explain about RMI Architecture?

613


What state does a thread enter when it terminates its processing?

611


Describe, in general, how java's garbage collector works?

541


What is the difference between RMI registry and OS Agent?

635


Define aop(assepct oriented programing)?

644






What restrictions are placed on the location of a package statement within a source code file?

622


What modifiers may be used with an inner class that is a member of an outer class?

580


What are the types of scaling?

560


What is prototype?

613


Where we can write Rmi registry in the code, without having to write it at the command prompt?

2266


hi friends, i have done my BE(CSE)at 2011 then i have joined one company before they asked me 50k so i paid but now they telling no project here so we r going to close like that so now i need any job i have good knowledge in core java and j2ee(jsp,servlet,jdbc) so if u know any job pl help me

1785


What class is used to create Server side object ?

1676


How primary key is implemented in Oracle?

1920


How are the elements of a cardlayout organized?

600


What is ripple effect?

638