Sobes.tech
Junior — Middle

What are the key characteristics of interfaces in programming?

sobes.tech AI

Answer from AI

Interfaces in programming have the following key characteristics:

  • Define a set of methods without implementation (in Java before version 8 — only abstract methods).
  • Describe a contract that classes must implement.
  • Support multiple inheritance of types (a class can implement multiple interfaces).
  • In Java 8+, they can contain default methods with implementation and static methods.
  • Do not contain state (instance variables), only constants (static final).

Example of an interface in Java:

public interface Drawable {
    void draw(); // method without implementation

    default void print() {
        System.out.println("Drawing");
    }
}