This may be a design problem raising it's hand and asking for a fix. One very common problem is using subclassing where roles would be more appropriate. For example one might model a base person class and subclasses for student and instructor. Then when a grad student teaches a course you find you can't really change her from student to instructor. A better model might have a concrete person with pluggable behavior - do some student behavior now, do some instructor behavior later.
Did that makes sense? Does it connect with your situation??
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Your method's signature can return a base object, but the actual entity it returns must be the object you intend to cast to. I will give you an example, but I must say this is really bad design and should be replaced with interfaces plus some of what the other commentors' said.
You can also always use instanceof as a last resot to avoid ClassCastExceptions.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com