Explain the difference between call by refrence and call by value?

devquora
devquora

Posted On: Jan 08, 2021

 

The difference between call by reference and call by value

ParametersCall by valueCall by reference
DefinitionWhile calling a function, when you pass values by copying variables, it is known as "Call By Values."While calling a function, in programming language instead of copying the values of variables, the address of the variables is used it is known as "Call By References.
ArgumentsA copy of the variable is passed in this method.A variable itself is passed in this method.
Alteration of valueIt does not allow you to make any changes in the actual variables.It allows you to make changes in the values of variables by using function calls.
EffectChanges made in a copy of the variable never modify the value of the variable outside the function.Change in the variable also affects the value of the variable outside the function.
Alteration of valueIt does not allow you to make any changes in the actual variables.It allows you to make changes in the values of variables by using function calls.
Passing of variableValues of variables are passed using a straightforward method.Pointer variables are required to store the address of variables.
Value modificationOriginal value not modified.The original value is modified.
Memory LocationActual and formal arguments will be created in different memory locationActual and formal arguments will be created in the same memory location
SafetyActual arguments remain safe as they cannot be modified accidentally.Actual arguments are not Safe. They can be accidentally modified, so you need to handle arguments operations carefully.

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    Capgemini Java interview questions

    What is database normalization? Explain types of it.

    In SQL, normalization of data is a process through with data is organized in tables used for the reduction of redundancy and dependency of data. It divides large tables into smaller ones using some se...

    Capgemini Java interview questions

    What is difference between Class and object In JAVA?

    Difference between Class and object In JAVA:Class - A class is like a blueprint. It is the class with the help of which objects are created. The class holds together data and methods in one single...