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

What are constants and how to create constants in java?

552


What are the types of inner classes (non-static nested class) used in java?

556


What is tcp and udp?

593


Is oracle charging for java?

542


Explain about public and private access specifiers?

529






How do I print a “?

567


Can we override private method in java?

611


How is it possible for two string objects with identical values not to be equal under the == operator?

521


Is java 1.7 the same as java 7?

526


What do you mean by ternary operator in java?

552


What is a “stateless” protocol ?

549


What is the file type?

551


What is array length?

499


How to run a JAR file through command prompt?

708


Can java cast null?

593