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
Why bean class is used in java?
I run a web server. Am I at risk? : java security
Explain working of java virtual machine (jvm)?
How do you count in java?
How does jpa repository work?
what is reflection api? How are they implemented?
Explain issues of old java date api?
What is custom tag in java?
What is lambda expression in mvc?
What is the java api?
Why oracle type 4 driver is named as oracle thin driver?
Can an application have multiple classes having main method?
What is ehcache in java?
What is the difference between Logical Parallelism and Physical Parallelism?
Explain the inheritance principle.