Would this be considered composition?
Statement st=con.CreateStatement();
I believe this is correct. The con.CreateStatement()
I think is an example of Factory methods which returns an object. I guess this would be somewhat similar to a constructor. We then assign it or cast it to the Statement
reference which gives us access to the Statement
methods. So now our Statement
object has functionality of the connection object and access to the Statement
methods. Would this be considered composition?
No, that's not composition. That's just an Abstract Factory Pattern.
Composition is discussed for example in the well known Prefer Composition over Inheritance "rule".