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 the RMI and Socket?
What is in-memory replication?
What is the highest-level event class of the event-delegation model?
What is a clone?
What is the difference between long.class and long.type?
Can you give me a simple example of using the requiredif validator rule?
What modifiers may be used with an inner class that is a member of an outer class?
How to deploy Jar, War files in J2EE?
Name the eight primitive java types.
What restrictions are placed on the location of a package statement within a source code file?
What is mdb and what is the special feature of that?
What are the types of scaling?
Which characters may be used as the second character of an identifier, but not as the first character of an identifier?
What is the relation between the infobus and rmi?
Write a singleton program?