Question discussion

In Java, what happens if a class implements two interfaces that both declare a default method with the same signature, and the class does n…

558Medium DSSSB TGT Computer Science 0 replies 1 views
0
In Java, what happens if a class implements two interfaces that both declare a default method with the same signature, and the class does not override it?
  • AIt compiles fine, using the method from the first interface in declaration order
  • BA compilation error occurs due to ambiguity, requiring an explicit override
  • CJava automatically merges both default method bodies
  • DIt causes a runtime exception only when the method is called
Correct answer: B

Discussion 0

Nobody has replied yet. Start the discussion!