Which of the following is true?
(A) A method cannot change the value of a primitive type that's passed to it
(B) A method can change the data in a reference type that's passed to it
(C) A method can directly manipulate the instance variables without passing around
(D) All of the above
Solution:-
D) All of the above
Explanation:-
When we pass primitive value to method the manipulation done by method does not effect the original variable. Here we just pass value of variable not variable.
But in case when we pass reference of variable to method the manipulation done by variable will effect the value of original variable
If we want to manipulation instance variable via method we can directly use that variable without pass it to calling method.
Hence All of the above options are correct
Get Answers For Free
Most questions answered within 1 hours.