Answer Posted / manoj kumar
public class DateUtil implements Serializable,Cloneable {
private static volatile Dateutil instance;
private DateUtil() {
//no-op
}
public static DateUtil getInstance() {
if(instance==null) {
synchronized(DateUtil.this) {
if(instance==null) {
instance = new DateUtil();
}
}
return instance;
}
protected Object readResolve() {
return instance;
}
public Object clone() throws CloneNotSupportedException {
super.clone();
throw new CloneNotSupportedException;
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How does a for loop work java?
What is serialization in java?
What are the important features of Java 9 release?
is it possible to instantiate the math class?
Where is core java used?
Explain about object oriented programming and its features?
Why string is not a wrapper class?
When does a class need a virtual destructor?
How do you do a line break in java?
Can we able to pass objects as an arguments in java?
What are the differences between stringbuffer and stringbuilder?
Where is the find and replace?
What is final method in java?
What Is Composition?
How many ways can you break a singleton class in java?