What is the singleton class in java?

Answer Posted / paletipatisrinu

singleton class:A java class create only one object per jvm
is called singleton java class.Most of jdbc driver class
implemented as a singleton java class

Ex:
class SingletonClass
{
private static SingletonClass singleObject;
public static SingletonClass getInstance()
{
if (singleObject == null)
{
singleObject = new SingletonClass();
}
return singleObject;
}
}

Singletone java class example is
org.apache.struts.action.ActionServlet

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is jpa a framework?

627


What is injection in java?

684


What is jep in java?

648


In java thread programming, which method is a must implementation for all threads?

725


Can we install jre without jdk?

667


In hibernate what is the difference between the Session and SessionFactory?

714


What is data encapsulation?

722


Can the main method be overloaded?

738


How long can a lambda function run?

679


What is java web application?

638


What does persist mean in java?

709


What is a context in java?

626


What is the difference between the boolean & operator and the && operator?

690


What is java ioc?

661


Why is lambda expression used?

657