Differentiate between call by value and call by reference.
Advertisements
Questions
Differentiate between call by value and call by reference.
Give the difference between call by value and call by reference.
Distinguish Between
Advertisements
Solution
| Sr. No. | Call by value | Call by reference |
| 1. | Pass-by value transfers a copy of the actual parameters to the formal parameters. | Pass by reference refers to conveying the address of actual parameters to formal parameters. |
| 2. | Changes in formal parameters do not affect actual parameters. | Changes to formal parameters will be mirrored in actual parameters. |
| 3. | Call by value is typically used for primitive data types (e.g., int, char). | Use call-by-reference for non-primitive data types, such as objects and arrays. |
shaalaa.com
Is there an error in this question or solution?
Chapter 5: User - Defined Methods - EXERCISES [Page 337]
