Does Java have pass by value or pass by reference or both?Please Explain it with example.

Showing Answers 1 - 4 of 4 Answers

preeta

  • Sep 25th, 2006
 

"pass by value" and  "pass by ref" are both defined in java. In pass by value technique.....a copy of aurguments are passed to the method......( exp: sum(10,5) and in pass by ref technique.....a ref to the values are passed to the method.....(exp: sum(a,b))

  Was this answer useful?  Yes

Ajay

  • Oct 15th, 2006
 

java has both i.e. pass by value and pass by ref. When primitive types are passed, they are passed by value but when objects are passed, they are passed by ref. And reference itself is passed by value.

  Was this answer useful?  Yes

ajaykjha

  • Oct 15th, 2006
 

java has both pass by value and pass by ref. When primitive types are passed, they are passed by value but when objects are passed, they are passed by ref. And reference itself is passed by value.

  Was this answer useful?  Yes

Casttro

  • Mar 15th, 2007
 

Java is defined in both "pass by value" and  "pass by ref" . In pass by value technique is just a copy of aurguments are passed to the method ( EX: cal(20,5.225) and in pass by ref technique is just a ref to the values are passed to the method (EX:cal(Cat, Dog))

  Was this answer useful?  Yes

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