हिंदी

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

Advertisements
Advertisements

प्रश्न

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

Explain Call by Value and Call by Reference.

स्पष्ट कीजिए
कारण बताइए
Advertisements

उत्तर

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
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 3: User-Defined Methods - Exercises [पृष्ठ ९१]

APPEARS IN

रुपा पंडित Computer Applications [English] Class 10 ICSE
अध्याय 3 User-Defined Methods
Exercises | Q 5. (v) | पृष्ठ ९१
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×