What Is an Interface?
An interface is a special type in programming that only declares what methods a class should have — not how those methods work. Think of it as: A toy blueprint — shows what parts the toy must have, but not the colors or materials. A remote control — has buttons (methods) you can press, but it doesn’t say what happens inside the TV. A promise/contract — “If you say you implement me, you must give me all these methods.” Why? Interfaces help us write flexible code where different classes can be used in the same way, even if they work differently inside. How Interfaces Differ from Classes and Abstract Classes Example 1 — Single Interface Implemented by a Class interface Flyable { void fly(); } class Bird implements Flyable { public void fly() { System.out.println("Bird is flying"); } } public class Main { public static void main(String[] args) { Bird b = new Bird(); b.fly(); } } ...