Hello Friends,

I am Shailesh Patel doing MCA(5th Semester) from Ahmedabad. I am pretty impressed with the site and i would like to share my study knowledge to people who came across this site. This is my first post on this site. Give me feedback in comments. Thanks to Administrator (Rakshit Patel) to give me chance to share my knowledge through site.

May be you are worried why Java doesn't support multiple inheritance ? The reasons for omitting multiple inheritance from the Java language mostly step from the "simple, object oriented, and familiar" goal. As a simple language, Java's creators wanted a language that most developers could grasp without extensive training. To that end, they worked to make the language as similar to C++ as possible (familiar) without carrying over C++'s unnecessary complexity (simple).

Now look at below example , how the Java support Multiple Inheritance. Java supports multiple inheritance indirectly through the use of interface. In case we are able to extend more than one class then there would be a confusion of which method to process in case both classes have same method name(Same method signature also).

In case of using interfaces to support multiple inheritance we escape this problem as we define the methods that are needed only. Some important rules when we do use interface are…
1) All Method of Interface are Abstract
2) We don't write definition of Method in Interface
3) We don't create the object of Interface,We Must create Reference of Interface

Exemple :
interface One
{
//methods without definition
}
interface Two
{ //methods without definition
}
//Multiple Inheritance in java
class Final implements One,Two
{
One obj=New One();//Error(Object of Interface)
One obj=New Final();//Reference of Interface
//definition of all method
}

To know more about programming,JavaScript issues,jQuery,Expression Engine,MYSQL database,php info,php editor,programming php,Open-source,php help and php script , subscribe to our feed by entering email address below. You will get updates via email about every tutorial posted on this site . It will not take more than a sec.

Enter your email address:
 
Feel free to ask any question. Just leave your comment below and we will answer your comment with in 24 hours.
rax rss  Java supports Multiple Inheritance through Interface   rax twitter  Java supports Multiple Inheritance through Interface   rax facebook  Java supports Multiple Inheritance through Interface

No related posts.

To know more about programming,JavaScript issues,jQuery,Expression Engine,MYSQL database and Open-source, enter your email address below. We will send you free tutorials.

Enter your email address:
 
Feel free to ask any question. Just leave your comment below and we will answer your comment with in 24 hours.