Skills101
← All practice quizzes

Quiz: Inheritance and Polymorphism

5 questionsNo time limitPass: 60%+10 XP on first pass

Reuse code with extends, call the parent with super, override methods, and understand runtime polymorphism (dynamic dispatch), overloading vs overriding and the final keyword.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    What does this print?

    class A { String who() { return "A"; } }
    class B extends A { String who() { return "B"; } }
    public class Main {
        public static void main(String[] args) {
            A obj = new B();
            System.out.println(obj.who());
        }
    }
    
  2. Question 2

    Where must super(...) appear in a constructor?

  3. Question 3

    Overriding is an example of:

  4. Question 4

    Which class can't be extended?

  5. Question 5

    How many classes can a Java class directly extend?