🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: SOLID Principles: all 10 questions

Quiz: SOLID Principles · Question 3 of 10

What does this print? (code)

What does this print?

class Base:
    def apply(self, x):
        return x

class Double(Base):
    def apply(self, x):
        return x * 2

class AddTen(Base):
    def apply(self, x):
        return x + 10

total = 5
for step in [Double(), AddTen(), Base()]:
    total = step.apply(total)
print(total)
  1. A.30
  2. B.25
  3. C.10
  4. D.20
Answer & explanation

Correct answer: 20

5 doubled is 10, plus 10 is 20, and Base returns it unchanged.

Can you get the rest right without peeking?

Take the timed Quiz: SOLID Principles quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →