What is singleton class?

Answer Posted / nagarjuna

Singletonclass is a class which can be instantiated only once.
public class Singleton
{
private static single = new Singleton();

Private Singleton();
{}
}

For a singleton class, the constructor is made private and
a static variable is used for instatiating the class.

Is This Answer Correct ?    4 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between multitasking and multithreading in Java

719


Is null a string or object in java?

548


How do you make an arraylist empty in java?

475


Is main is a keyword?

579


What is procedure writing?

509






Can you have two constructors in java?

501


Implement a stack with push (), pop() and min() in O(1) time.

630


Write a program to check string is palindrome without using loop?

565


What is increment in java?

524


What are the two basic ways in which classes that can be run as threads may be defined?

549


How many types of constructors are used in java?

539


What are multiple inheritances? Is it supported by java?

460


What is one third plus one third as a fraction?

485


What is the symbol for line break?

608


What exactly is java?

513