Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: JDBC
Expertise: Beginner
Sep 25, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

ResultSet Interface

If ResultSet is an interface, then why can we call methods like
next(), isLast()
etc. without defining the method body anywhere in the program? As I understand it, in an interface, methods are only declared but not defined.

Even though an interface does not implement any of its methods, a class that implements an interface will implement the interface's methods. When you obtain a reference to a ResultSet through a JDBC call, you are getting an instance of a class that implements the ResultSet interface. This class provides concrete implementations of all of the ResultSet methods.

Interfaces are used to divorce implementation from, well, interface. This allows the creation of generic algorithms and the abstraction of object creation. For example, JDBC drivers for different databases will return different ResultSet implementations, but you don't have to change your code to make it work with the different drivers.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date