Sobes.tech
Principal

Explain what an interface is at a junior developer level.

sobes.tech AI

Answer from AI

An interface is like a contract or a template that describes what methods a class must implement. It does not contain the implementation of these methods, only their signatures (name, parameters, and return type).

For example, if we have an interface Animal with a method makeSound(), then any class that implements this interface (for example, Dog or Cat) must define how exactly it makes a sound.

This helps in writing code that works with different objects through a common interface, without worrying about the implementation details.