Interface
An interface is a contract that lists the methods a class must provide, without saying how they work. Any class that fulfils it can be used interchangeably.
General Programming
Interfaces let code depend on what an object can do, not on its specific type. Languages like Java and TypeScript have explicit interfaces; Python relies on 'duck typing' to achieve the same idea.
Examples
Java
interface Shape {
double area();
}
class Square implements Shape {
public double area() { return 4.0; }
}
System.out.println(new Square().area());Output:
4.0