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

What is native class in java?

496


What is java language expression?

493


When is static variable loaded? Is it at compile time or runtime? When exactly a static block is loaded in java?

493


Is jpa a framework?

454


I am trying to create a new universal user group. Why can't i? : java security

511






How common are security breaches? : java security

447


ioc vs dependency injection?

1906


How do I run a java project?

484


Is it better to learn java or python?

457


In which language eclipse is developed?

465


What is lazy loading in jpa?

437


What is the difference between a jvm and a jdk?

523


How do I download and install eclipse on windows 10?

431


What's the difference between code-based security and role-based security? Which one is better? : java security

499


How do I install java on windows?

455