what is private constructor?what are the uses of writing
private constructor in our program?

Answer Posted / christian

a common use for a private constructor is to implement the
singletton pattern, which uses a public member variable of
the same type of the class which is defined. A public
getInstance() method uses this private constructor

Is This Answer Correct ?    13 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why is string class considered immutable?

598


Explain the difference between protected and default access.

520


How garbage collection is done in java?

553


What is string data type?

559


What is the final variable?

585






What will be the output of round(3.7) and ceil(3.7)?

685


There are two classes named classa and classb. Both classes are in the same package. Can a private member of classa can be accessed by an object of classb?

1005


Is 0 a prime number?

575


What is the major drawback of internal iteration over external iteration?

591


How many bytes is a string?

570


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

530


What are the elements of java?

569


What is reverse function?

582


What is object of class in java?

603


What is maximum size of arraylist in java?

499