Machine-translated by Google. Questions are authored in English.
Top

Discussion

Objects life time generally corresponds to which storage allocation mechanism from the following :

(i) Static objects
(ii) Stack objects
(iii) Heap objects
(iv) Serialised objects

  • A.(i), (ii) and (iv)
  • B.(i), (ii) and (iii)
  • C.(i), (iii) and (iv)
  • D.(ii) and (iii)

Answer: B

The answer is (i), (ii) and (iii).

An object's lifetime is tied to how its storage is allocated. Static objects live for the whole run of the program, stack (automatic) objects live from their declaration until their block exits, and heap (dynamic) objects live from explicit allocation until they are freed or garbage collected. These are the three classic storage allocation strategies.

Serialisation turns an object into a byte stream for storage or transmission. It is not a storage allocation mechanism, so options naming (iv) are wrong, and (ii) and (iii) alone leaves out static objects.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.