Junior — Middle
Can you name the main types of interfaces used in programming?
sobes.tech AI
Answer from AI
In programming, interfaces come in different types depending on the context:
- User Interface (UI) — a graphical or text-based way for the user to interact with the program.
- Application Programming Interface (API) — a set of functions and methods through which one program interacts with another.
- Interface in Object-Oriented Programming — an abstract type that defines a set of methods that classes must implement.
In Go, an interface is a set of methods that a type must implement. Example of an interface in Go:
type Reader interface {
Read(p []byte) (n int, err error)
}
Any type that implements the Read method automatically implements the Reader interface.