Ask Question

Which of the following is not possible? A class that implements two interfaces. A class that inherits from two classes. A class that inherits from one class, and implements an interface. All of these are possible.

+1
Answers (1)
  1. 7 January, 15:11
    0
    "A class that inherits from two classes"

    Explanation:

    If we're talking about Java, you can't extend from two classes. The reason for this is Java doesn't allow multiple inheritance.

    The reason for this is to avoid the ambiguity caused by it. One of the cases where multiple inheritance can cause ambiguity is the diamond problem.

    Diamond problem can occur if two classes (say B and C) inherit from one class (say A). And another class (say D) inherits from both B & C.

    If B and C class override the same method from A class. And D class calls that method, which one will be called, class B's or C's?
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Which of the following is not possible? A class that implements two interfaces. A class that inherits from two classes. A class that ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers