Expert View
As a software engineer, I often found that interviews on interfaces are not meant to test memory — they test your understanding of abstraction and design thinking. A confident student should be able to explain how interfaces define contracts, enable modular design, and support loose coupling in real-world projects. Many fresh graduates at NBKRIST initially overlook small but important details such as access modifiers, default/static methods, or how multiple inheritance is achieved. Remember — in interviews, clarity and confidence matter more than syntax perfection.
Core Conceptual Questions
1. What is an interface in Java?
An interface is a contract that specifies what methods a class must implement, promoting abstraction and loose coupling.
2. How is an interface different from an abstract class?
An interface can’t have constructors and supports multiple inheritance; abstract classes can have constructors and partial implementations.
3. Why can’t we instantiate an interface?
Interfaces don’t provide concrete implementations; they only declare method signatures.
4. What are the access modifiers allowed in interface methods?
All interface methods are implicitly public and abstract (unless static or default).
5. Can an interface extend another interface?
Yes. Interfaces can extend one or more interfaces using the extends keyword.
Implementation & Usage Questions
6. How do you implement an interface in a class?
By using the implements keyword and providing implementations for all its abstract methods.
7. Can a class implement multiple interfaces?
Yes, a class can implement multiple interfaces — this is how Java achieves multiple inheritance.
8. What happens if a class fails to implement all methods of an interface?
The class must be declared abstract; otherwise, a compilation error occurs.
9. Can interfaces have variables?
Yes, but all variables are implicitly public static final — constants.
10. What is the default access modifier for members of an interface?
Members are public by default, even if you don’t specify it.
Java 8+ Feature Questions
11. What are default methods in interfaces?
Methods with a body introduced in Java 8 to add new behavior without breaking existing code.
12. What are static methods in interfaces?
Static methods belong to the interface itself and are called using the interface name.
13. What are private methods in interfaces (Java 9)?
Private methods in interfaces help reuse logic among default or static methods inside the same interface.
14. What is a functional interface?
An interface that contains exactly one abstract method, used for lambda expressions.
15. Give examples of functional interfaces from Java API.
Runnable, Callable, Predicate, Consumer, Supplier, Function.
Design & Real-World Questions
16. Why are interfaces preferred in real-world projects?
They decouple implementation from definition, improving maintainability and scalability.
17. How do interfaces support polymorphism?
A variable of interface type can refer to any object implementing that interface, enabling dynamic method binding.
18. Can an interface be empty?
Yes. Such interfaces are called marker interfaces (e.g., Serializable, Cloneable).
19. What’s the use of marker interfaces?
They convey metadata to the JVM or frameworks to perform specific behavior.
20. What are common mistakes students make with interfaces?
Forgetting implicit modifiers, misunderstanding multiple inheritance, or confusing interface constants with instance variables.
Quick Recap by Expert
In interviews, the focus isn’t just on definitions — it’s on how you apply concepts. If you can explain why interfaces exist, how they improve software design, and what benefits they bring in large-scale systems, you’ve already succeeded. Remember: Interfaces represent the promise of behavior — not the behavior itself.