GeekInterview.com
Series: Subject: Topic:
Question: 11 of 37

what is the difference between call by value, call by reference, call by address?

No answers
Asked by: bhatiagagan5 | Member Since Oct-2007 | Asked on: Oct 25th, 2007

View all questions by bhatiagagan5

Showing Answers 1 - 8 of 8 Answers
jamanat

Answered On : Dec 26th, 2007

View all answers by jamanat

I guess call by value and call by reference everyone knows. In Java:Call By value - premitive types passed in the method call, push their values on stack and hence said as called by Values.Call By Reference - All objects passed to any method call, pass their reference on stack and hence said as called by reference.Remiaining is call by address (should be same as call by reference), if not, the person may be addressing following:     Static final member variables (constants) passed in the method call which are in the permanent memory and only the address (or reference) is pushed on stack. As the value on this address can not be changed (only read), the person is refering it as address and not reference.Hope this helps. Even if you dont answer the person exactly, if you give above answer, interview pannel will understand that your concepts are clear and that's what you need to show.Thanks,Jamanat

Yes  1 User has rated as useful.
  
Login to rate this answer.
sampra

Answered On : Feb 13th, 2008

View all answers by sampra

Java support call by value only

Yes  1 User has rated as useful.
  
Login to rate this answer.
sachidanand

Answered On : Apr 15th, 2008

View all answers by sachidanand

Call by value: A copy of the argument is passed as parameter. So the caller method and the called method are working on different sets of data. Changing one doesn't affect the otherCall by reference:The address of the object on the heap, w.r.t java, is passed as the parameter. So modifying one will have an effect on the other.Call by address: same as call by reference.Hope your question is answered, if not already answered.

  
Login to rate this answer.
kayalsuku

Answered On : Jun 2nd, 2008

View all answers by kayalsuku

Java Does not support call by reference and it only support CALL BY VALUE

  
Login to rate this answer.
abhatnagar192006

Answered On : Aug 4th, 2008

JAVA does not support call by reference. As far as call by value is concerned..it means that java primitives are passed as arguments to a method. Eg: void swapNumbers (int a, int b) ; When we talk of passing by reference...we are actually passing "object references" by value. Eg: Class Student{.................}Class containsMain{public static void main (String args[]) {        Student rajeev = new Student ("rajeev") ;    Student mohan = new Student("mohan") ;        void swapObjects ( rajeev, mohan) ; .............................}}In the implementation of swapObjects, we have the folowing...swapObjects (Student x, Student y) { Student temp = new Student (" "); temp = x; x = y; y = temp; }Before, This function is invoked, x refers to rajeev and y refers to mohan.During the function call, the reference of rajeev is copied to x and that of mohan is copied to y. In the method, the object references are swapped. However, when the method returns, x and y are abandoned, while the original references of the objects rajeev and mohan are still the same. If JAVA supported call by reference, the swap would be successful..but it was not.Summary: JAVA does not support call by reference, but only passing on references of objects by valueAayush

  
Login to rate this answer.
prasoon.go

Answered On : Mar 21st, 2009

View all answers by prasoon.go

In call by value, value is passed and in call by reference, base address is passed.

  
Login to rate this answer.
mani_miit

Answered On : Dec 14th, 2009

View all answers by mani_miit

Call by value--->You are passing primitive value for your method argument.call by ref--->You are passing objectcall by address-->reference and address both are same.

  
Login to rate this answer.
Milan unjiya

Answered On : Jan 2nd, 2014

Call by value---> when we pass normal variable in method, it is call by value.

Call by reference---> when we pass object as parameter, it is passed by reference.

Call by address---> call by reference and call by address both are same.

  
Login to rate this answer.

Give your answer:

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

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.