English

State a Difference Between Call by Value and Call by Reference. - Computer Applications

Advertisements
Advertisements

Question

State a difference between call by value and call by reference. 

Distinguish Between

Solution

Call by Value Call by Reference
(i) In call by value the method creates its new set of variables (formal parameters) to copy the value of actual parameters and works with them. (i) In call by reference, reference of the actual parameters is passed on to the method. No new set of variables is created.  
(ii) Any change made in the formal parameter is not reflected in the actual parameter.  (ii) Any change made in the formal parameter is always reflected in the actual parameters.
(iii) Primitive data types are passed by call by value.  (iii) Reference types like (objects, array etc.) are passed by call by reference.
shaalaa.com
  Is there an error in this question or solution?
2018-2019 (March) Set 1
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×