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
When arithmeticexception is thrown?
Why array is used in java?
Can a serialized object be transferred via network?
When is the finalize() called?
What is fail first in java?
What is super constructor?
Why charat is used in java?
Is java owned by oracle?
Explain the difference between an Interface and an Abstract class?
What is the use of default method in interface in java?
How to read and write image from a file ?
What is meant by class loader? How many types are there? When will we use them?
What is the difference between == and === javascript?
Is this valid in java ? Can we instantiate interface in java?
How to create a base64 decoder in java8?