Java OCA OCP Practice Question 1543

Question

Fill in the blank:

The primary reason default interface methods were added to Java is to support ___.

  • A. polymorphism
  • B. concrete methods in interfaces
  • C. multiple inheritance
  • D. backward compatibility


D.

Note

Java was updated to include default interface methods in order to support backward compatibility of interfaces.

By adding a default method to an existing interface, we can create a new version of the interface, which can be used without breaking the functionality of existing classes that implement an older version of the interface.

Option D is the correct answer.

Options A and C are not applicable to default interface methods, whereas Option B could be achieved by using static interface methods.




PreviousNext

Related