Computer Applications

What are benefits/drawbacks of temporary instances ?

Java Constructors

6 Likes

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.

Answered By

4 Likes


Related Questions