Q. What is the purpose of the ‘interface’ keyword in Java?

A
To create a new class
B
To define a contract of methods that implementing classes must follow
C
To handle exceptions
D
To declare a variable
Solution:

An interface specifies a set of methods that a class must implement, enforcing a contract.

Entri Contact Image

Get Expert Advice for Free: Register for Your Free Consultation Now!