What is diamond problem?

What is diamond problem?

Suppose You are having the four classes named A, B, C, and D. Assume that class A is the superclass of class B and class C. Now in a programming language, that support multiple inheritance, class D can inherit from the two classes B and C. Suppose class A has a variable v and this variable is inherited in the classes B and C. Again v is inherited by the class D from B and C. Now class D has indirectly inherited variable v form the class A but class D contain two version of the variable b inherited from classes B and C. This is the reason that Java does not support Multiple inheritance. This problem is called diamong problem, because if we desing it graphically, it looks like a diamond shape.

Date:2015-01-09 00:00:00

Post Your Answers

User Email:

User Name:

Related Java Subjective Links

Java Subjective interview questions and answers for experienced and fresher