Computer Applications

Can you think of the benefits of a private class if any ? What are they ?

Java Constructors

7 Likes

Answer

The benefits of a private class (i.e., a class with a private constructor) are:

  1. Controlled object creation — By making the constructor private, we can control the number of objects of a class that can be created. We can also enforce certain rules or constraints on how the object is created and used.
  2. Better memory management — By limiting the number of objects of a class that can be created, we can reduce memory usage and improve performance.

Answered By

4 Likes


Related Questions