I would like to know some procedure by which I can restrict multiple child classes of a given class in java.
e.g. if I have class A then only one class can extend A i.e. no more than 1 child class is allowed.
I had been asked this question in a company interview and would really appreciate some help or direction.
You might be able to prevent anyone using more than one subclass, via the mechanism linked by Sujay (see comments). The superclass constructor/methods could track what subclasses are calling them, remember the first one, and throw exceptions if another subclass is used. Not very elegant, and probably not very useful (but then this is an interview question).
Update: Is this what you are after (from http://www.drmaciver.com/2007/09/how-to-create-sealed-classes-in-java/)?
You can’t create further subclasses outside of the Sealed class because the constructor is not visible…