How to prevent to create multiple objects of a java class?
Answers were Sorted based on User's Feedback
Answer / sadiq
Using Singleton Design pattern we can prevent class creating
multiple objects.
Is This Answer Correct ? | 30 Yes | 3 No |
Answer / naseer
declare constructor as private .that class only create one object
Is This Answer Correct ? | 10 Yes | 6 No |
What is class??
Is it possible to cast an int value into a byte variable? What would happen if the value of int is larger than byte?
Which types of exceptions are caught at compile time?
What is difference between checked and unchecked exception in java?
What is the root class for all Java classes?
how to get the max salary and name of employee from arraylist without using the Comperator or even Comparable interface?
Why java strings are immutable in nature?
What does int argc char * argv [] mean?
can you program for reverse string?
What is Gang of four design patterns
What is empty string literal in java?
What is double data type?