Python OOP MCQ Test: 200 Interview Questions With Answers

← All Python MCQ topics and your readiness dashboard

Test your Object-Oriented Programming knowledge with a timed Python MCQ mock test for interviews. Each attempt gives you 20 random questions in 20 minutes from a 200-question bank covering classes, instances and self, class versus instance attributes, inheritance, super() and the MRO, name mangling, properties, static and class methods, dunder methods such as __repr__, __eq__, __len__ and __call__, dataclasses, abstract base classes, enums, composition and SOLID ideas, and the Page Object Model, builders, fakes and mocks for QA. 46 questions are written from a QA and test-automation angle and the rest from a developer angle; your result shows both scores.

What this Python MCQ test covers

Revise these lessons from the free Python tutorial before or after your test:

Sample Python OOP questions with answers

  • Q. A minimal page object. What does this code print?
    class FakePage:
    def __init__(self):
    self.filled = {}
    def fill(self, sel, value):
    self.filled[sel] = value
    def click(self, sel):
    self.clicked = sel
    class LoginPage:
    def __init__(self, page):
    self.page = page
    def login(self, user, pwd):
    self.page.fill("#user", user)
    self.page.fill("#pwd", pwd)
    self.page.click("#submit")
    return self
    p = FakePage()
    LoginPage(p).login("asha", "x1")
    print(p.filled, p.clicked)

    Answer: {'#user': 'asha', '#pwd': 'x1'} #submit
    A page object wraps locators and actions; tests call login() instead of raw steps.
  • Q. Page objects returning the next page. What does this code print?
    class Dashboard:
    title = "Dashboard"
    class Login:
    def login(self, u, p):
    return Dashboard()
    nxt = Login().login("asha", "x")
    print(type(nxt).__name__, nxt.title)

    Answer: Dashboard Dashboard
    Returning the next page object makes a test read as a flow.
  • Q. A base page with shared helpers. What does this code print?
    class BasePage:
    url = "/"
    def open(self):
    return f"goto {self.url}"
    class CartPage(BasePage):
    url = "/cart"
    class HomePage(BasePage):
    pass
    print(CartPage().open(), "|", HomePage().open())

    Answer: goto /cart | goto /
    Subclasses override only the url; the open() logic lives once in the base class.
  • Q. What does this code print?
    class User:
    def __init__(self, name):
    self.name = name
    u = User("Asha")
    print(u.name)

    Answer: Asha
    __init__ sets the instance attribute name.
  • Q. What does this code print?
    class User:
    pass
    u = User()
    print(type(u).__name__, isinstance(u, User))

    Answer: User True
    An instance belongs to its class.
  • Q. What does this code print?
    class Counter:
    count = 0
    def __init__(self):
    Counter.count += 1
    Counter(); Counter(); Counter()
    print(Counter.count)

    Answer: 3
    A class attribute is shared by the class and all instances.

Every predict-the-output question in this bank was run on Python 3, so the answer is the real output. Go back to the Python MCQ dashboard to see your overall Python learning progress and interview readiness.

Frequently asked questions

How many questions does the Python OOP MCQ test have?

The bank has 200 questions. Each test picks 20 at random, favouring questions you have not seen yet, so about 10 attempts cover the whole bank.

How long is each test and what is the pass mark?

Each test has a 20-minute timer and submits itself when time runs out. You pass with 70%, which is 14 of 20 correct.

Is this test useful for QA and automation engineer interviews?

Yes. 46 of the questions use test-automation scenarios such as parsing UI text, test data and assertions, and your result shows your QA score separately.

Can I retake the test?

Yes, as often as you like. Every retake draws a fresh set of 20 questions and counts toward your 20-test readiness target.