← All AP CSA Flashcard Decks

Interfaces and Abstract Classes Flashcards

7 cards from real AP CSA practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.

Read the first 7 Interfaces and Abstract Classes flashcards as text
  1. Which keyword is used to declare an interface in Java?

    Answer: interface

    The `interface` keyword declares an interface in Java, defining a contract of method signatures without implementations.

  2. Which keyword does a class use to adopt an interface?

    Answer: implements

    A class uses the `implements` keyword to adopt one or more interfaces and provide concrete implementations for their methods.

  3. By default, all methods declared inside an interface are:

    Answer: public and abstract

    Interface methods are implicitly public and abstract, meaning any implementing class must provide a concrete implementation.

  4. What happens if a class implements an interface but does not override all of its abstract methods?

    Answer: The class must be declared abstract

    If a class does not implement all abstract methods of an interface, it must itself be declared abstract; otherwise, the code will not compile.

  5. Can a single class in Java implement more than one interface?

    Answer: Yes, by listing them separated by commas after implements

    Java allows a class to implement multiple interfaces by listing them after the `implements` keyword, separated by commas.

  6. Which of the following is TRUE about variables declared inside an interface?

    Answer: They are public, static, and final by default

    Variables declared in an interface are implicitly public, static, and final — they are constants that cannot be changed.

  7. Which of the following best describes the purpose of an interface in Java?

    Answer: To define a contract specifying what methods a class must implement

    An interface defines a contract — a set of method signatures — that any implementing class must fulfill, promoting abstraction and polymorphism.