Omooop 9
Omooop 9
Description:
When we pass a primitive type to a method, it is passed by value. But when we pass an object to a method,
the situation changes dramatically, because objects are passed by what is effectively call-by-reference.
Java does this interesting thing that’s sort of a hybrid between pass-by-value and pass-by-reference.
Basically, a parameter cannot be changed by the function, but the function can ask the parameter to change
itself via calling some method within it.
● While creating a variable of a class type, we only create a reference to an object. Thus, when we pass
this reference to a method, the parameter that receives it will refer to the same object as that referred to
by the argument.
● This effectively means that objects act as if they are passed to methods by use of call-by-reference.
● Changes to the object inside the method do reflect in the object used as an argument.
CONCLUSION: Students are expected to List the error they are facing along with their solution