โ† All SCJP Flashcard Decks

Java OOP and Inheritance Flashcards

6 cards from real SCJP practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 6 Java OOP and Inheritance flashcards as text
  1. Which keyword is used in Java to prevent a class from being subclassed?

    Answer: final

    The `final` keyword applied to a class prevents any other class from extending it.

  2. What is the output of calling a method on an object reference declared as the superclass type but pointing to a subclass instance?

    Answer: Subclass method runs due to dynamic dispatch

    Java uses dynamic method dispatch (runtime polymorphism), so the overridden subclass method is called.

  3. Which of the following is true about abstract classes in Java?

    Answer: They can contain both abstract and concrete methods

    Abstract classes can have both abstract methods (no body) and concrete methods (with body).

  4. In Java, what is the result if a subclass defines a static method with the same signature as a static method in its superclass?

    Answer: Method hiding occurs

    When a subclass defines a static method with the same signature as the superclass, it hides the superclass method rather than overriding it.

  5. Which access modifier allows a method to be accessed within the same package and by subclasses in other packages?

    Answer: protected

    `protected` grants access within the same package and to subclasses regardless of package.

  6. What happens when a subclass constructor does not explicitly call a superclass constructor?

    Answer: The default no-arg superclass constructor is called implicitly

    Java automatically inserts a call to the superclass no-arg constructor (`super()`) as the first statement if not explicitly provided.

How this page was made: written with AI tools and published by Nathan Beja, founder of Practice Test Geeks, who is responsible for its content. We have not yet matched this exam's facts to an official source, so confirm fees, dates and rules with the exam body. Not reviewed by a subject-matter expert. Editorial policy