What is an interface in Java?
Why Interviewers Ask This
This is a classic screening question for Java roles. Hiring managers ask it early in interviews to gauge your baseline understanding and determine if you can communicate technical concepts clearly.
Answer
An interface is a reference type in Java that defines a contract — a set of abstract methods that implementing classes must provide. Interfaces support multiple inheritance: a class can implement multiple interfaces. Before Java 8, interface methods were all abstract and public. Since Java 8, interfaces can have default methods (concrete methods with a default implementation) and static methods. Since Java 9, they can have private methods. All fields in an interface are implicitly public static final. Use interfaces to define capabilities (e.g., Comparable, Serializable, Runnable) that unrelated classes can implement.
Pro Tip
Back up your answer with a specific project or situation. Saying 'In my last Java project, I used this when...' immediately makes your answer more credible and memorable.
Previous
What is an abstract class in Java?
Next
What is the difference between abstract class and interface in Java?