Рет қаралды 40,728
Diamond problem (in inheritance) is an ambiguity problem that can arise as a consequence of allowing multiple inheritance through default methods that were introduced in java 8.
Udemy Course of Code Decode on Microservice k8s AWS CICD link:
openinapp.co/u...
Course Description Video :
yt.openinapp.c...
Multiple Inheritance is a feature of object oriented concept, where a class can inherit properties of more than one parent class. The problem occurs when there exist methods with same signature in both the super classes and subclass. On calling the method, the compiler cannot determine which class method to be called and even on calling which class method gets the priority.
In order to avoid Diamond problem in inheritance or ambiguity Java does not support multiple inheritance of classes. It is keeping the things simple and straightforward.
You can achieve multiple inheritance in Java, using the default methods (Java8) and interfaces.
#diamondprobleminjava #ambiguityinjava #java8