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 hql in java?
What is meant by pass by reference and pass by value in java?
What is the difference between Logical Parallelism and Physical Parallelism?
What is custom tag in java?
What is java bean class?
What is a singleton in java?
explain isalive() method under thread class?
Is java a framework?
What is an api in java?
What are orm tools in java?
explain how java se 8 data and time api solves issues of old java date api?
What happens when the parent process of a child process exits before the child ?
What are jpa annotations?
Which is best framework in java?
How can the static main method use instance variables?