ICSE Class 10 Computer Applications Question 12 of 19

Constructors — Question 12

Back to all questions
12
Question

Question 12

What are benefits/drawbacks of temporary instances ?

Answer

The benefit of temporary instances is that they live in the memory as long as they are being used or referenced in an expression and after this, they are deleted by the compiler. The memory is freed as soon as they are deleted rather than staying in the memory till the program completes execution.

The drawback of temporary instances is that they are anonymous i.e., they do not bear a name. Thus, they cannot be reused in a program.