Surya,
You were probably looking at a class that represented an implementation of the singleton design
pattern. Part of the definition of a singleton is that only one instance of it can be created, and code like what you described is often used to enforce that restriction. By making the constructor private, you ensure that other classes can't create multiple instances of the singleton class, and the accessor method can be used to return a reference to the one instance that is allowed to exist.
If what you're really asking is when it's appropriate to use a singleton, I'd suggest that you take a look at the "Gang of Four"
Design Patterns book or one of the other titles that describes when and how to use the singleton pattern.
------------------
Brett Spell
Author,
Professional Java Programming [This message has been edited by Brett Spell (edited March 22, 2001).]