Advanced Java Question:

Does Java pass arguments by value or reference?

Tweet Share WhatsApp

Answer:

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.

Download Advanced Java PDF Read All 24 Advanced Java Questions
Previous QuestionNext Question
Will it be called overriding if I do not change the parameters or return type, instead throw a different exception in the method signature?Different between Struts and Spring? or Why use Spring, if you are already using Struts?