How many objects are created in the following code snippet?
a = 10
b = a
c = b
Answer : one
a is assigned the value 10, creating an integer object with the value 10.
b is assigned the value of a, so it refers to the same integer object as a. No new object is created in this step; it just points to the existing object.
c is assigned the value of b, so it also refers to the same integer object as a and b. Again, no new object is created in this step.
0 Comments:
Post a Comment