Skip to content
Sharp

Object-oriented programming · interview question

How can private methods in interfaces be useful in Java?

Multiple choiceHardchapter-5-curatedpremiumoopinterfaces
Choose one answer
Answer and explanation

Correct answer

B. They allow for encapsulating helper methods shared by default and static methods within the interface.

Why

Private methods in interfaces, introduced in Java 9, allow encapsulation of common code used by default and static methods within the interface, promoting reusability and reducing duplication.

Test yourself on Object-oriented programming

A free test with instant, explained results. No account needed.

Start free test
All Object-oriented programming questions →