What is an interface in Java?

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.

Key Points

Example

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();
    }
}

Common Mistakes

Follow-up Questions

Interview Tip

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?

More Core Java - Level I interview questions

All Core Java - Level I questions