Have a look at the "Factory" pattern. It can have a series of interfaces that define specific behaviors, with the implementations provided by a factory class.
In this case the object handle is declared using the type of interface needed. The instance is received from the Connection class via one of its methods: createStatement(), prepareCall() or prepareStatement(). Considering the tight coupling between a Statement object and the associated Connection object, this makes a lot of sense.
The Statement interface provides access to the base behavior, and is extended by the PreparedStatement, which is further extended by the CallableStatement.
[ July 07, 2003: Message edited by: Philip Shanks ]
When I have gone through your answer, I got a question as given below:
What is "Factory"
pattern?
What are the Factory classes?
Where can I find these classes and Factory Pattern?
Do you have any documentation for this ,if you have any documentation or article on this please send it to me.