English

Answer the following in brief. Give a reason/example wherever applicable. Explain Call by Value and Call by Reference.

Advertisements
Advertisements

Question

Answer the following in brief. Give a reason/example wherever applicable.

Explain Call by Value and Call by Reference.

Explain
Give Reasons
Advertisements

Solution

Call by Value:
In call by value, a copy of the actual value is passed to the method. Any changes made inside the method do not affect the original variable.

  • Example:
void update(int x)
{
x = 20;
}
  • Reason: The method receives a separate copy of the value.

Call by Reference:

In call by reference, the reference of the original data is passed to the method. Changes made inside the method affect the original data.

  • Example: Passing an object reference to a method can modify the object's data.
  • Reason: The method accesses the same memory location of the origina
shaalaa.com
  Is there an error in this question or solution?
Chapter 3: User-Defined Methods - Exercises [Page 91]

APPEARS IN

Rupa Pandit Computer Applications [English] Class 10 ICSE
Chapter 3 User-Defined Methods
Exercises | Q 5. (v) | Page 91
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×