Computer Science, asked by sujaychintakunta, 11 months ago

15) When we write X=10 and Y=X, which of the following memory assignment is correct
a) X and Y will have same location and 10 will be stored.
Ob) X and Y will have two distinct locations and 10 will be stored in both
c) X and Y will have same location and only X will contain value 10
d) X and Y will have two distinct locations and only X will contain value 10​

Answers

Answered by ankurbadani84
3

Answer:

b) X and Y will have two distinct locations and 10 will be stored in both

Explanation:

Correct answer is - b) X and Y will have two distinct locations and 10 will be stored in both.

Only when pointers are used the location of X and Y comes into picture. Here there are no pointers used.

In above example only value stored in X and Y are made same to 10. Hence correct answer is Option B.

Answered by lovingheart
3

Answer:

Option B. X and Y will have two distinct locations and 10 will be stored in both is the right answer.

Explanation:

Here X will be assigned a location and during the assignment operation X = 10, the value 10 will be stored in the location. In the next line Y= X, Y would have been allotted a different memory location and then the value of X is copied to the location of Y and thus Y gets the value of 10. This is called as Shallow copy where only values get copied and not reference.

Similar questions