what is the use of declaring constructor as private?

Answer Posted / anshul

A private constructor is a special instance constructor. It is commonly used in classes that contain static members only. If a class has one or more private constructors and no public constructors, then other classes (except nested classes) are not allowed to create instances of this class.

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

why would you use a synchronized block vs. Synchronized method? : Java thread

525


Can we extend singleton class?

525


Explain about collection interface in java?

536


Can we use different return types for methods when overridden?

548


Can you inherit from an abstract class java?

520






What is a line break example?

567


Explain what are final variable in java?

564


What is an i/o filter?

557


Does unicode support all languages?

509


What is a 16 bit word?

555


Are registers volatile?

521


What is the difference between yield() and sleep()?

534


How many bytes is a char in java?

520


What do you mean by flow of struts?

737


Can you pass functions in java?

561