Why Multiple inheritance not supported in Java?
- Consider class A, class B java same method show() and class C extends both class A ,class B.
- Now at this point Java compiler doesn't know which class method needs to be invoked. It creates an ambiguity to java compiler. So, Multiple inheritances not supported through class.
- To prevent ambiguity error to java compiler, multiple inheritances can be achieved through interfaces because in interfaces implementation of interface methods is provided in a separate class.
No comments:
Post a Comment
Please comment below to feedback or ask questions.