Answer Posted / hardeep thakur
Here is code to implement the singleton
public class SingletonClass {
private static SingletonClass singleObj ;
private SingletonClass(){}
public static synchronized SingletonClass getInstance()
{
if(singleObj ==null){
singleObj = new SingletonClass();
}
return singleObj;
}
public Object clone() throws CloneNotSupportedException
{
throw new CloneNotSupportedException();
}
}
| Is This Answer Correct ? | 7 Yes | 0 No |
Post New Answer View All Answers
In a class implementing an interface, can we change the value of any variable defined in the interface?
What is a linkedhashmap java?
How we create object in copy constructor?
What is instanceof keyword?
Write down program for following scenario. Use java coding standard. You have array list with some words in it..we will call it as dictionary….and you have a arbitrary string containing some chars in it. You have to go through each word of dictionary and find out if that word can be constructed with the help of chars from arbitrary string given. If you find the word print it else print none.
Write a program to print the pattern given below
What is the exact difference in between Unicast and Multicast object? Where will it be used?
What is data type example?
What is a consumer in java?
What is array and arraylist in java?
What is nested class?
What is the use of System class?
What’s the difference between unit, integration and functional testing?
How big is a gigabyte?
What does java stand for?