Skills101
← All practice quizzes

Quiz: Polymorphism

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

One interface, many forms. Method overloading and overriding, dynamic dispatch, duck typing in Python, operator overloading, and why polymorphism makes code easy to extend.

Log in to take the quiz

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

  1. Question 1

    Method overriding is an example of:

  2. Question 2

    Two methods in the same class named add(int, int) and add(double, double) show:

  3. Question 3

    What does this print?

    class A:
        def show(self): return "A"
    class B(A):
        def show(self): return "B"
    items = [A(), B(), A()]
    print("".join(x.show() for x in items))
    
  4. Question 4

    "Duck typing" in Python means:

  5. Question 5

    Which method lets a + b work for your own Python class?