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
What are methods in java?
Is integer a class?
What is entry in java?
Distinguish between a predicate and a function?
What does localhost mean?
What is constructor in java ?
Can you declare a private method as static?
Explain about varargs in java?
What is Mutex (Mutual Exclusion Object) ?
Is 64bit faster than 32 bit?
Which of the following classes will have more memory allocated?
Why object class is super class for every class in java?
Differentiate between a class and an object.
How is it possible in java programming for two string objects with identical values not to be equal under the == operator?
How to split a string in java?