0% found this document useful (0 votes)
2K views1 page

OOP Practical Paper

This document provides instructions for a practical exam in object oriented programming. It consists of 4 questions worth 25 marks each. Students must write C++ programs to: 1) Accept integer or double values, add them, and return the correct output using functions. 2) Implement inheritance to evaluate student performance using multiple classes. 3) Create base and derived shape classes to compute and display the area of different shapes. 4) Create a shape hierarchy with a base class and derived classes, making a virtual function to verify behavior through pointers.

Uploaded by

Talha Awan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views1 page

OOP Practical Paper

This document provides instructions for a practical exam in object oriented programming. It consists of 4 questions worth 25 marks each. Students must write C++ programs to: 1) Accept integer or double values, add them, and return the correct output using functions. 2) Implement inheritance to evaluate student performance using multiple classes. 3) Create base and derived shape classes to compute and display the area of different shapes. 4) Create a shape hierarchy with a base class and derived classes, making a virtual function to verify behavior through pointers.

Uploaded by

Talha Awan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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