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
Can I map more than one table in a cmp?
What is the immediate superclass of the applet class?
what is a portable component?
What classes of exceptions may be caught by a catch clause?
Describe activation process?
What are the types of scaling?
What are the diff types of exception?
What value does read() return when it has reached the end of a file?
What is a class loader?
What do you mean by Socket Programming?
What is the difference between a static and a non-static inner class?
How task's priority is used in scheduling?
What are the call back methods in entity bean?
Can you give me a simple example of using the requiredif validator rule?
What is the difference between the font and fontmetrics classes?