Your school name
2nd Year Computer Chapter 3 Test2nd Year · Computer · Punjab (PTB)
Q1. Multiple choice questions (Attempt all · 10 × 1 = 10)
OOP allows code to be divided into modules, which promotes:
An object is defined as a(n):
The main idea behind encapsulation in OOP is:
Unlike languages like Java or C++, Python controls data access primarily using:
The OOP concept that hides data inside a class is:
What mechanism does Python use to alter the internal name of a double-underscore variable to prevent accidental outside access?
Inheritance allows a class to:
Multilevel inheritance occurs when a class inherits from:
Polymorphism in OOP is best defined as:
When a child class provides a specific implementation of a method that is already defined in its parent class, it is called:
Q2. Short questions (Attempt any 6 of 8 · 6 × 2 = 12)
What are two primary benefits of using inheritance?
What is the difference between compile-time and runtime polymorphism?
How many types of Inheritance are there?
Define Encapsulation.
Why is signature-based method overloading unnecessary in Python?
Define multiple inheritance.
How is inheritance specified in Python class syntax?
What is the purpose of a class in Python?
Q3. Long questions (Attempt any 2 of 3 · 2 × 4 = 8)
Write a python code to demonstrate the concept of Runtime polymorphism (Overriding) by creating classes Animal, Dog and Cat.
Explain the concept and structure of Multilevel Inheritance, describing how properties and behaviors are passed down through successive levels of derived classes using a multi-generational chain (Grandparent --> Parent --> Child).
Write a Python program to demonstrate multiple inheritance by creating Father and Mother base classes and a Child derived class that accesses methods from both parent classes.