Refresh Your Java - Before Java Interview
We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....
Single class is a class for which only one Instance
will be created per JVM. Singleton
classes
would have
Private Constructors so that instances will not be
created from other
classes. In general Singleton classes
are used to hold the static data like Properties
or some
Constants in memory.
One difficulty you may face
with the Singleton classes is keeping them in SYNC among all
the JVMs in a clustered ENV, you have to have your own
mechanism for accomplish this.
Or you could avoid using
singleton classes by using some popular In-Memory cache APIs
such as EHCache, which give you the opportunity of using their
built-in Distributed Cache
features for clustered
ENV.
Here is the sample:
class
PropertyManager {
private
static PropertyManager propManager;
private PropertyManager() {
}
public static PropertyManager
getInstance() {
if (null == propManager) {
propManager = new PropertyManager();
}
return propManager;
}
}
This Portal is intended to put all Java/J2ee related topics at one single place for quick referance, not only Technical , but also the Project Management Related thing such as Development Process methodoogies build process, unit testing etc.,
This Portal has More than 500 Java Interview Questions (also could be Considered as Quick Notes) very neatly separated topic by topic with simple diagrams which makes you easily understandable. Importantly these are from our Realtime expericance.