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
Can we override private methods?
What is static variable with example?
Explain wrapper classes in java?
Is singleton thread safe in java?
What do you mean by constructor?
What is java literals?
Is a boolean variable?
What are the various access specifiers in java?
How will you compute size of a structure?
What are java packages? What's the significance of packages?
Can we override data members in java?
What is concurrent hashmap and its features?
What is the difference between length and length () in java?
what is use of functional interface in java 8?
What is volatile data type?