Sunday, July 29, 2012

How Interfaces are used internally in Java

Before reading this post, I recommend you to go through the following posts:
Interfaces in Java
Runtime Polymorphism in Java
Abstract Classes in Java : Runtime polymorphism

The interfaces have played a key role in making the architecture of Java robust and uniform. The interfaces are used in many places in Java. They are extensively used in JDBC architecture, Collections framework, Multi-threading etc., We will see in detail how interfaces have become crucial for Java to become robust and maintain the uniformity.

Interfaces used in JDBC:

Interfaces are so well used in architecture of JDBC by Java. I should say Java has got most of the flexibility mainly from interfaces and abstract classes. In fact, what Java has done is defined all the method-names in the interfaces. It did not give any implementation for any of the methods. So, what the  DBMS has to do is just use these method-names and build implementation according to the DBMS implementation. In case of migration from one DBMS to other DBMS literally, only the database driver URL, username, password for connection have to be changed.

Now consider a situation without interfaces in Java. In such cases, each DBMS will have its own set of method-implementations and method-names for specific functionalities in Java. Eventually, the method-names for database processing such as executing SQL stored procedures will differ from one DBMS to other DBMS. Now if we want to just change the DBMS we need to change the entire database processing code instead of just changing the driver URL, username and password.


Interfaces used in Multi-Threading:

Similarly interfaces are critical in view of the multi-threading. We know that a thread can be created by two methods.
1. Extending Thread class.
2. Implementing Runnable interface.

Now the first method can impair you in one way. If you extend Thread class, there is no way that you can extend another class since multiple inheritance is not allowed in Java. Now the second option is always good since we can create a class that implements any number of interfaces.

Interfaces used in Collections framework:

Another place where Java has made use of the interfaces is the Collections framework. The Collection framework is the most basic interface. It contains methods to add, remove, search and iterate over list. These are most general functionalities provided. The List, Set and Queue interfaces extend the Collections interface. These interfaces have their specific functionalities in addition to those provided by the Collection interface.

Related Posts:
Interfaces in Java
Runtime Polymorphism in Java
Abstract Classes in Java : Runtime polymorphism
Java Database Connectivity with MS Access -- Part 1
Java Database Connectivity with MS Access -- Part 2
Java Database Connectivity with MS Access -- Part 3

6 comments:

  1. What is the Roku Activation code?
    Roku activation code is one that is mandatory to activate the Roku device. To get the code, you need to complete the initial steps on the Roku device. Only after this, you can get the code on the Roku device. For the activation, you can surf to the Roku activation page and enter the code on the site to activate the device. After the device activation to launch the channels on the Roku device, you need to sign in the Roku account to the Roku device If you want some more information about Roku Account please visit our site: Roku.com/link

    ReplyDelete
  2. How to Activate VH1 Application?
    First, you have to get the app from the channel store and go to the channel store by choosing the streaming channels option. Go to the Movies and TV section and get the app. Now, access the app and receive the code. After that, visit vh1.com/activate by opening a web browser. Then, opt for the pay TV provider and key in the channel link code to the text box. Finally, click Activate and initiate the process of activation If you want more information about vh1 channel activation please visit our site vh1 channel activation

    ReplyDelete
  3. Thanks for sharing this information
    Kiran Infertility Centre is one of the leading infertility treatment clinics in India with branches in Hyderabad, Gurgaon and Bengaluru and is perhaps the best fertility clinic in Hyderabad providing world class treatment options for Infertility such as Surrogacy, I.V.F., I.C.S.I., IUI, Egg/ Oocyte Donation, PGS/ Embryo Donation, Oocyte/Embryo Freezing.IVF Treatment in hyderabad

    ReplyDelete
  4. Students who get enrolled in contract law in the United States often find it hard to complete their assignments as well as concentrate on their studies. This is when they look for Contract Law Assignment Help online.

    ReplyDelete
  5. To abridge the tension cloud, you can stay connect with the Assignment Help provision. In this situation, you can find the rock solid hope to create the meaningful solution. It is up to call our professionals anywhere and anytime.

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...