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 gui in java with examples?
What are java’s rules regarding tabs, spaces and newline characters?
What's the difference between code-based security and role-based security? Which one is better? : java security
Why there are no global variables in java?
Do I really have to type in the programs in the book to try them out?
Which class is the superclass of every class?
What do I need to install netbeans?
What's the difference between authentication and authorization? : java security
What is an entity in java?
What is scrollable resultset in java?
What is crud operations in java?
In a barber shop there are 2 doors. customer come in 1 door, leave in other. minimum # of chairs. barber spend his life in cutting. always barber can cut 1 customer. few chairs in the shop. if barber busy customer waits, if chairs full, customer leave. if no customer, barber sleeps. treat barber and customer as 2 threads. you can use Semaphore class with arrive and depart and count as parameter.
What's the difference between local, global and universal groups? : java security
What are the disadvantages of java sockets?
What is jersey in java?