Important Questions - Unit 4
1. Explain the advantages of Object-Oriented Programming (OOP) over procedural programming
with examples.
2. What is class and object in Python? Explain with an example.
3. Define instance variables and class variables with examples.
4. Explain the lifecycle of an object in Python. How does Python handle object destruction?
5. Write a Python program to create a class Student with instance variables usn, name, and marks.
Create two objects and display the details of the student who has the highest mark.
6. Write a Python program to create a class Employee with the attributes: empid, empname,
empnohrs, empbasic, emphra(%), empda(%), empit(%), and empgross. Implement methods to
calculate gross salary based on given conditions.
7. Develop a Python program to create a class Circle with a member radius and methods to:
- Accept the radius from the user
- Find the area of the circle
- Find the perimeter of the circle
- Display all details
8. Explain inheritance in Python with an example. How does a child class access parent class
methods?
9. What is method overriding? Explain with an example in Python.
10. Explain multiple inheritance in Python with a suitable program.
11. What is operator overloading in Python? Explain with an example of overloading the `+` operator
for a user-defined class.
12. Write a Python program to overload the `>` (greater than) operator in a class.
13. Explain exception handling in Python with examples.
14. Write a Python program to check the validity of age. Raise an exception if the entered age is
negative.
15. Write a Python program that accepts two numbers from the user and performs their division.
Handle exceptions for division by zero and invalid input.