A class cannot extend two classes, but a class can implement multiple interfaces. So, we use interfaces to achieve multiple inheritance in Java programming.
e.g. Class C extends A, B { //statements }
The above class declaration is invalid in Java programming. but possible in various other programming languages.
e.g. Class C extends A implements D, F { //codes }
The above class declaration is valid in Java. In the above class declaration, we have inherited class A and implementing two interfaces D and F. This way we can implement multiple interfaces in Java.
Example Class C extends Class A and Class B and both classes A and B have evaluate() method. When class C tries to inherit evaluate method then the compiler will get confused and unable to decide which evaluate method to inherit, either from class A or B. So to remove this ambiguity from the program Java doesn't support multiple inheritance.
Example Class C extends Class A and Class B and both classes A and B have evaluate() method. When class C tries to inherit evaluate method then the compiler will get confused and unable to decide which evaluate method to inherit, either from class A or B. So to remove this ambiguity from the program Java doesn't support multiple inheritance.
java online training hyderabad
ReplyDeletejava training
ReplyDeleteThank you for sharing. It is very useful Blog.
ReplyDeleteAzure DevOps Training Online
Azure DevOps Online Training
Azure DevOps Training
Azure DevOps Training in Hyderabad
Microsoft Azure DevOps Online Training
Azure DevOps Course Online
Azure DevOps Online Training in Hyderabad
Thank you for sharing such an informative post. I appreciate the depth of research and clarity in your writing. Keep up the excellent work! Looking forward to reading more from you in the future.
ReplyDeleteDevOps Training in Electronic City Bangalore
Thank you for sharing such an informative post. I appreciate the depth of research and clarity in your writing. Keep up the excellent work! Looking forward to reading more from you in the future.
ReplyDeleteDevOps Training in Electronic City Bangalore
It was a helpful article.
ReplyDeleteDevOps Training in Marathahalli Bangalore
Your blog has become a go-to resource for me. Thanks for consistently providing valuable content!
ReplyDeleteMicrosoft Azure DevOps Training Course (AZ-400)