Practical 9
Practical 9
Aakash Dagar500107152
Batch-12
AIM:
Classes and Objects
Q1.
Create a class of student (name, sap id, marks (phy, chem, maths)). Create 3 objects by taking
inputs from the user and display details of all students.
Answer:
Q2.
Add constructor in the above class to initialize student details of n students and implement
following methods-
a) Display() student details
b) Find marks_percentage() of each student
c) Display result() Note: If marks in each subject>40% then pass else fail. Write a
function to find average of the class.
Answer:
Q3.
Create programs to implement different types of inheritances.
a) Single inheritance
b) Multiple inheritance
c) Hierarchical inheritance
d) Multilevel inheritance
Answer:
Q4.
Create a class to implement method overriding.
Answer:
Q5.
Create a class for operator overloading which adds two point objects where point has x and y
values.
For example-
If P1 (x=10, y=20), p2 (x=12, y=15) then P3=P1+P2->P3 (x=22, y=35)
Answer: