Reputation: 3
Here we have created an object of an interface. How's that even possible?
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","xweb","abc");
Upvotes: 0
Views: 66
Reputation: 2566
No, you are creating a instance of a class that implements the interface. What that means is that you do not need to know the concrete class implementation of the object, just that it implements Connection, and as such has all the methods defined in interface Connection. If you look at con.getClass(), you will see what the actual class is.
Upvotes: 1