Answer Posted / naman patidar
A singleton class can never have more then one instance.
Example :
class SingletonClass {
private static SingletonClass singleObject;
public static SingletonClass getInstance() {
if (singleObject == null) {
singleObject = new SingletonClass();
}
return singleObject;
}
}
| Is This Answer Correct ? | 3 Yes | 2 No |
Post New Answer View All Answers
What is the first argument of the string array in main method?
What are microservices in java?
Spring framework ---Can somebody explain me in easily understandable format about AOP, IOC and DI, so that i can explain in interview rather than just telling what is available in net. I am not able to understand that also. I am new to Spring
What is microservices java?
What is ibatis in java?
Why doesn't lsdou work under windows nt? : java security
What is the difference between Logical Parallelism and Physical Parallelism?
Why doesn’t the main method throw an error with no arguments?
How should I format my code? How should I comment my code?
What java systems libraries and methods are available for me to use?
How do you run an executable jar file?
What are orm tools in java?
How do I install jdk?
What is jpa entitymanager?
What is hql in java?