Jump to content

Interface (object-oriented programming)

From Simple English Wikipedia, the free encyclopedia

Interfaces are abstract data types. They usually only contain method signatures, which are names and parameters, and the kind of data type to be returned. They do not contain the body of the method, also known as implementation. A class or object that has a matching method signature, will contain the implementation and do the actual work.

In object-oriented programming, interfaces are similar to traits, except for: 1) traits may contain method bodies (implementation), 2) interfaces may contain both signatures and fields (variables).

Some notable languages that support interfaces: Ada, D, Go, Java, Swift, and V (Vlang)

[change | change source]