Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

why java does not support multiple inheritance

Answer Posted / professor pandit

Java does not support multiple inheritance of classes.
Answer as to its reasons on why it does not support MI runs
much deeper than what generally seems to be written above.

Java like all OO languages aims to regulate and stream-line
the way in which average developer thinks. It is true that
in real world (from software designer perspective), an
entity, an object does exhibit functions from seemingly
different sets (aka classes).

It is true that implementing multiple inheritance is
difficult at compiler level and complexity is hardly ever
clearly explained in any example. Every single example of
MI that demonstrates its complexity seems contrived and are
generally name-collisions. Assuming that I did seriously
want to inherit class C from both A and B, why on earth
would I give same names to two distinct functions
originating from class A and class B? One could be foo()
and other could be foofoo(); (I hope you get the drift).

C++ designers bent-over-their-back and solved the problem
of MI and even the diamond problem.

Although, Diamond problem is successfully handled by C++,
any sane designer team could have a coding standards that
favour avoidance Diamond inheritance until the die-hard
developer convinces upper crust of its essentials.

Ironically, the major part of Java's decision on "why" of
avoiding MI lies in C++ implementation of it.

While I am grossly simplifying here, Crux of C++ solution
of implementing MI under the hood hinges upon properly
managing the v-table at run-time and unambigious usage of
redundant methods ( in case of diamond) are handled.

In case of Java, design goal was operability across
multiple platforms and industrial strength stability.

Both of these goals can be seriously compromised if MI (and
C++ solution of v-table) were implemented.

Therefore, Java designers choose to let go of a smaller
nice-to-have feature (MI for classes) in favour of Multiple
Platform (essential design goal)

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can constructor return value?

909


If an object is garbage collected, can it become reachable again?

954


What is the preferred size of a component in java programming?

964


Which method must be implemented by all threads?

1203


Can a final variable be initialized in constructor?

927


What is hotjava?

962


If an object reference is set to null, will the garbage collector immediately free the memory held by that object?

1096


Can we have more than one package statement in the source file?

1027


Can we sort hashmap in java?

909


Can list be null in java?

992


What is the difference between menuitem and checkboxmenu item?

1285


What is the difference between double and float variables in java?

1092


I have multiple constructors defined in a class. Is it possible to call a constructor from another constructor’s body?

962


Name and explain the types of ways which are used to pass arguments in any function in java.

1023


What are the advantages of arraylist over arrays?

1047