what is singleton class? where it mainly used in the
projects?

Answers were Sorted based on User's Feedback



what is singleton class? where it mainly used in the projects?..

Answer / jhuma

singleton class is such kind of class in which only one
object is created throughout the life time of the class.

class Singleton
{
public static Singletone si;
private Singletone()
{
si=new Singletone();
}
public static Singletone show()
{
return si;
}
public static void main(String ar[])
{
Singleton s1=Singletone.show();
}
}

Is This Answer Correct ?    44 Yes 22 No

what is singleton class? where it mainly used in the projects?..

Answer / niraj

singleton means single. singleton class is that class
which have only one object , or in which class has only one
object .

Is This Answer Correct ?    17 Yes 3 No

what is singleton class? where it mainly used in the projects?..

Answer / rameshkrishna

singleton means create the one and only object per class
that per jvm

---use to decrese globel variables
---to provide the encapsulation

Is This Answer Correct ?    13 Yes 5 No

what is singleton class? where it mainly used in the projects?..

Answer / suresh jv

Singleton class is a class, it allows jvm to create only one
object.
note:
most of the people think that servlet is a singleton class.
but it is not a singleton class. Actually for each servlet
one object will be created by container.
But suppose if u want to create another object for same
servlet, that servlet allows us to create another object but
the container (server) will not allow to create second object.

When a huge amount of requests coming to servlet, some of
the servers (espcially weblogic)allows to create second
object for same servlet to handle huge amount of requests,
then how can u say servlet is a singleton class.
"The class, itself doesn't allow to create second object "
is called singleton class.

this helps a lot u.....

Is This Answer Correct ?    1 Yes 1 No

what is singleton class? where it mainly used in the projects?..

Answer / rani

An Java API using Singleton is

java.util.Date

Is This Answer Correct ?    8 Yes 14 No

Post New Answer

More Advanced Java Interview Questions

What is a sessionfactory? Is it a thread-safe object?

0 Answers  


what are getters and setters in Java with examples?

0 Answers   HCL, Infotech,


What are externizable interface?

0 Answers  


1) which method of the RequestDispatcher cannot be called once the output is sent to the client? a. forward b. include c. both a&b 2) which interface should an object implement to get notified of changes to the list of active sessions in a web application? a. HttpSessionListener b. HttpSessionActivationListener c. HttpSessionAttributeLIstener 3) A user can select multiple locations from a list box on an HTML form, which of the following methods can be used to retrieve all the selected location? a. getParameter() b. getParameterValues() c. getParamValues() 4) which of the following methods should be used to send character text to the client? a. ServletResponse.getWriter() b. ServletResponse.getOutputStream() c. ServletResponse.getOut() 5) which implicit object is always available in a JSP page? a. exception b. session c. out 6) which inclusion mechanism doesn't include the source of the page, rather the output of the page. a. include directive b. jsp:include action c. Bothe a& b 7) which attribute of the page controls whether a page participates in session or not? a. session-allowed b. session c. isSession

1 Answers  


why static class in java

0 Answers   Infotech, SunGard,






What is glasgow?

0 Answers  


what is Activation Instantinator?

0 Answers  


Where can I ask questions and make suggestions about seam?

0 Answers  


what is a dirty read?

1 Answers  


What is resource bundle?

1 Answers  


What classes of exceptions may be caught by a catch clause?

0 Answers  


How to determine applet?s height and width?

1 Answers  


Categories