What happens if the argument you want ro pass is an object instead of a primitive?

Questions by krishna_darl   answers by krishna_darl

Showing Answers 1 - 2 of 2 Answers

kalya

  • May 22nd, 2006
 

in case of primitives the parameter is passed by value. in case of objects the parameter is passed by reference.

  Was this answer useful?  Yes

          In java there is no "pass by reference", we have only "pass by value". When an object reference variable is passed , the value stored inside the reference variable will be passed i.e., the address of the Object that the reference variable points to. So, we can access the members of the object by using the reference value passed to the method. But unlike in c/c++ we can't change the value of the reference variable (which is passed to the method) inside the method. 

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions