Does Java pass arguments by value or reference?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to determine SGA site?

1908


What is the relationship between an event-listener interface and an event-adapter class?

554


what is a non-repeatable read?

1828


Is a class a subclass of itself?

588


What is in-memory replication?

558






Is there a guarantee of uniqueness for entity beans?

569


What is the purpose of the finally clause of a try-catch-finally statement?

555


What is the difference between java class and bean?

579


When a thread blocks on i/o?

566


Why is string immutable in java?

578


Explain the advantages and disadvantages of detached objects.

577


What is TL and its use?

1991


How database connectivity in XML is achieved?

1766


Name the eight primitive java types.

593


What is threadfactory?

616