what is the use of private constructor in core java?
Answers were Sorted based on User's Feedback
Answer / rakesh
Private constructor can be used if we do not want any other
class to instantiate the class. This concept is generally
used in Singleton Design Pattern. The instantiation of such
classes is done from a static public method.
| Is This Answer Correct ? | 54 Yes | 3 No |
Answer / rajib
Whenever we r using singleton class then we use constructor
as private.
| Is This Answer Correct ? | 38 Yes | 6 No |
Answer / deep chandra harbola
private constructor are used to create Sinleton class.
example logger class
for singleton class only one object can be created.
by default member of singleton class are static.
singleton class can not be inherited.
| Is This Answer Correct ? | 29 Yes | 3 No |
Q) I have a ArrayList object, in that object i have added 5 integer values, 5 float values, 5 string values. Now question is how can delete particular type of data ( i.e all int values or all float values or string values) in that list object at a time?
What is type safety in java?
Name some classes present in java.util.regex package.
How do you reverse a list?
How many types of memory areas are allocated by JVM in java?
What are parsers? Dom vs sax parser.
Does anyone still use java?
What is private protected in java?
What is meant by attribute?
Is stringwriter thread safe?
Is array synchronized in java?
What about method local inner classes or local inner classes in java?