Question discussion

Since Java 8, which keyword allows a method of an interface to have a body that the implementing classes inherit unless they override it?

2536Medium DSSSB TGT Computer Science 0 replies

Since Java 8, which keyword allows a method of an interface to have a body that the implementing classes inherit unless they override it?

  • Aabstract
  • Bfinal
  • Cdefault
  • Dsynchronized
Correct answer: C

Explanation

A default method provides a ready-made implementation inside the interface, so a new method can be added to an interface without breaking the classes that already implement it.

Discussion 0

Nobody has replied yet. Start the discussion!