An interface in Java is a blueprint that defines a set of methods that implementing classes must provide. It is primarily used to achieve abstraction, loose coupling, and multiple inheritance in Java.
Consider a Payment interface that defines a makePayment() method. Different classes such as CreditCardPayment and UPIPayment can provide their own implementations of this method.
interface Payment {
void makePayment();
}
class UPIPayment implements Payment {
@Override
public void makePayment() {
System.out.println("Payment made using UPI");
}
}
public class Main {
public static void main(String[] args) {
Payment payment = new UPIPayment();
payment.makePayment();
}
}A concise interview answer is
An interface is a contract that defines a set of behaviors for implementing classes. It is used to achieve abstraction, loose coupling, and multiple inheritance in Java.
Last updated: 11 November 2026
Previous question: Explain encapsulation with an example in Java.
Next question: What is an abstract class in Java?