Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
This is a discussion on why multiple inheritance is not supported by java? within the Java forums, part of the Software Development category; why multiple inheritance is not supported by java?...
|
|||||||
|
|||
|
why multiple inheritance is not supported by java?
|
| The Following 2 Users Say Thank You to varanasisaikarthik For This Useful Post: | ||
| Sponsored Links |
|
|||
|
Re: why multiple inheritance is not supported by java?
that is because if a child is inheriting from two classes ,and if both the parent classes have the same method (same signature and same return type),the compiler will be confused as the method in the child overrides which parent
|
| The Following User Says Thank You to raghavrules For This Useful Post: | ||
|
|||
|
Re: why multiple inheritance is not supported by java?
in c++ also the multiple inheritance is there but due to ur saying reason we use the virtual function in c++.In java also we can use the virtual function so whats the deffect to use the multiple inheritance
|
|
|||
|
Re: why multiple inheritance is not supported by java?
actually we can use it,but indirectly witn the help of interfaces..
but my qs. is why not directly..? |
| The Following User Says Thank You to shreya suri For This Useful Post: | ||
|
|||
|
Re: why multiple inheritance is not supported by java?
Hi ,
Interface is the collection of methods with empty implementations and constants variables ( variables with static and final declarations ). All the methods in an interface are "public and abstract" by default. Since interfaces are abstract in nature so they can not be directly instantiated. To define the methods of an interface the keyword "implements" is used. Eg: interface check { public void message(); } public class Interface { public static void main(String[] args) { try { check t = new check() { public void message() { System.out.println("Method defined in the interface"); } }; t.message(); } catch (Exception ex) { System.out.println("" + ex.getMessage()); } } } If any query let me know.... Thanks, Riju. |
|
|||
|
Re: why multiple inheritance is not supported by java?
i dont think just because making the java simple and robust we don't have mulitple inhertiance and if it so why do they provided Interface concept for us....
and one thing more that we can have same method name with same return type via METHOD OVERRIDING... |
|
|||
|
interfaces are there in java to support polymorphism not for multiple inheritance java not at all support multiple inheritance
|
|
|||
|
Re: why multiple inheritance is not supported by java?
hi fnds
in java we have diamond property . i.m if the two parent class have the same method signature and different implementations the the jvm confused which parent class method it invoke....... this naming convention is called diamond property in java. thats y in java it doesn't support multiple inheritance directly, but it suppots indirect multiple inheritance throw interfaces bcz if the two in interfaces having same name even thow that method implementation existeds only once in the child class .....so there is no confusion to jvm which method implementation it invoke......... |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| multiple inheritance in java... | psuresh1982 | Java | 20 | 07-23-2007 02:33 PM |
| Default add-ins supported by the QTP 9.2 | Geek_Guest | QTP | 1 | 07-11-2007 03:50 PM |
| Clarification regarding Java Interface and Inheritance | Geek_Guest | JSP | 4 | 06-15-2007 08:46 AM |
| multiple inheritance.... | psuresh1982 | Java | 2 | 01-22-2007 12:57 AM |
| Applications supported by QTP | deeptik_81 | QTP | 2 | 12-19-2006 05:00 AM |