← All 1Z0-811 Flashcard Decks

Java Class Design Flashcards

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

Read the first 7 Java Class Design flashcards as text
  1. Which keyword prevents a class from being subclassed in Java?

    Answer: final

    The `final` keyword on a class declaration prevents any other class from extending it.

  2. What is the result of calling a non-static method on a null reference in Java?

    Answer: NullPointerException at runtime

    Invoking an instance method on a null reference throws NullPointerException at runtime.

  3. Which access modifier makes a member accessible only within its own class?

    Answer: private

    `private` restricts visibility strictly to the declaring class itself.

  4. Given `class B extends A`, and both define `void print()`, what determines which `print()` runs when called via an `A` reference holding a `B` object?

    Answer: The object type (B) — runtime polymorphism

    Java uses dynamic dispatch: the actual object type (B) determines which overridden method executes at runtime.

  5. What is the purpose of the `super()` call inside a constructor?

    Answer: To call the parent class constructor

    `super()` explicitly calls the parent class's constructor and must be the first statement in the child constructor.

  6. Which of the following is true about Java interfaces in Java 11?

    Answer: Interfaces can have private methods

    Since Java 9, interfaces can have private methods to share helper code between default methods.

  7. What happens if a class implements two interfaces that declare the same default method without overriding it?

    Answer: Compilation error due to ambiguity

    If a class inherits two conflicting default methods and does not override the method, a compile-time error occurs.