Hello Shasi Sekar,
I've not understood your question properly.
Class A generates two classes B and C
How? What do you mean by Class A 'generates' class B & C?
The class of B is constant
Again, what is meaning of a class being 'constant'? (and what is class 'of' B?)
Class B has getter and setter for Class C
Getter and setters are for instance variables. Here, you are simply creating new instance of C, invoking a method of C, which again creates new instance of C. So, technically, it is not a getter method.
I need to dynamically typecast the object to Class c. I have the class name as String,but running out of ideas to do it.
So, the class name is not C? Am I missing anything here? Because if class name is not C, then class B is not even gonna be compile (because a method of class B creates an object of class C).
Apart from this, what my understanding of your issue is - there is a String in your property file, that String is a class name, you want to create instance of that class and invoke some methods on it.
Well, it can very well be done by using Reflection APIs. Please check out classes like Class, Method etc.
Also, Oracle's tutorial on reflection is a good read.
Also, I would suggest to completely eliminate class B (if its only job is to give you object of Class C, then you can do it directly in Class A)
I hope this helps.