OOP Practical Paper

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Govt.

Gordon College Rawalpindi


Practical Exam Spring-2021
IT-107Object oriented programming (BS-IT 2nd Semester)
Total Marks:-100 Prof. Muhammad Saleem Bhatti
Time:- 150 minutes

Note: Each question carry 25 marks. Send solved script in pdf form on my personal number. Send answer sheet
with 10 minutes after allowed time. Late submission will not be allowed. Cheating will not tolerated.

Question 1:
Write a program that accepts two values either integer or double. Design functions that
understand the input, add them and provide the correct output.

Question 2:
Write a C++ program for student’s evaluation concept using inheritance.
Algorithm
Step1: create a class studentpersonal declare rollno, age, name, sex in protected mode.
Step2: Using a parameterized constructor initialize the values for all the data members.
Step3: Create another class studentmark that is inherited from the baseclass and having the
data members mark1 ,mark2 ,mark3,mark4 Using a parameterized constructor initialize the
value for mark1,mark2,mark3,mark4.
Step4: Create another class called studentsports and declare score as protected mode.
Step5: Create a class studentresult and public inherited form studentmarks and
studentsports having the data members total, avg, and grade.
Step6: Calculate the total and avg and display the result.

Question 3:
Create a base class called shape. Use this class to store two double type values that could be
used to compute the area of figures. Derive two specific classes called triangle and
rectangle from the base shape. Add to base class, a member function get_data() to initialize
base class data members and another member functions display_area() to compute and
display the area of figures. Mark the display_area() as virtual function and redefine this
function in the derived class to suit their requirements.(Use pure virtual function)

Question 4:
Create a simple “shape” hierarchy: a base class called Shape and derived classes called Circle,
Square, and Triangle. In the base class, make a virtual function called draw(), and override
this in the derived classes. Make an array of pointers to Shape objects that you create on the
heap (and thus perform up casting of the pointers), and calldraw() through the base-class
pointers, to verify the behavior of the virtual function if your debugger supports it, single-step
through the code.

You might also like