# Past Papers of Object-Oriented Programming

## Past Papers of Object-Oriented Programming

This is just a sample paper of Object-Oriented Programming. Nature of papers questions can depend on your university or instructor that how he is taking the course content. Now let’s see a sample paper of Object-Oriented Programming.

## Paper 1: Object-Oriented Programming

 Course Title: Object-Oriented Programming Course Code: Confidential Discipline /Program :  BSCS Total Marks:30 Time allowed: 2 Hour Instructor’s Name: Confidential

Note:

Attempt All Questions. Marks are written adjacent to each question.

Question No 1                                                                                                                        (6)

Question No 2                                                                                                                        (6)

What is polymorphism? Write a program using polymorphism in which user enters the number if the number is positive and the number is also even, then print the cube of the number and if the number is odd and negative then print the square of the number.

Question No 3                                                                                                                        (6)

Write a program using multi-level inheritance in which user enter a number, the program will show the table of the given number from 1 to 10.

Question No 4                                                                                                                        (6)

What is output for the following programs?

A.

B.

Question No 5:                                                                                                                       (6)

## Paper 2: Object-Oriented Programming

 Course Title: Object-Oriented Programming Course Code: Confidential Discipline /Program :  MCS Total Marks:30 Time allowed: 2 Hour Instructor’s Name: Confidential

Note:

Attempt All Questions. Marks are written adjacent to each question.

Question No 1                                                                                                                        (6)

What are single and multiple inheritances. Write a program to find the grades of a student using multiple inheritances according to the following rules;

Grade A if marks are > 80

Grade B if marks are >70 and < 80

Grade C if marks are > 50 and <70

Grade F if marks are < 40

Question No 2                                                                                                                        (6)

What is Multilevel inheritance? Write a program using multi-level inheritance in which the user enters the number, calculates the cube of the number, if the cube of the number is greater than 150 then print the square of the resultant cube, otherwise show the message “sorry”.

Question No 3                                                                                                                        (6)

Write a program in which users enter 5 numbers using for loop and all these numbers will store in an array. After that program will add these five numbers and show the result. Your program must support the concept of operator overloading.

Question No 4                                                                                                                        (6)

What is output for the following programs?

A.

B.

Question No 5: (6)                                                                                                                 (6)

Give one programming example of function overriding.

### Paper 3 – Open Book Paper of Object-Oriented Programming in C++

 Course Title: Object-Oriented Programming Course Code: Confidential Discipline /Program :  MCS Total Marks:30 Time allowed: 12 Hours Instructor’s Name: Confidential Theory Paper

Q#1                                                                                                                             7.5 Marks

Write a C++  program by using classes to show the sum of array rows and columns.

You must write this program by using a constructor and do while loop.

Q#2                                                                                                                 7.5 Marks

Write a C++ program by using classes  to find the greatest and lowest value from the array. If the greatest value is greater then 100, then print “its my good luck”, otherwise print ”its my bad luck”.

You must use while loop and using the user define function. Further user define function must be accessible by some another friend class.

Q#3                                                                                                                 7.5 Marks

Write a C++ program by using classes  in which user enter the three angles a1, a2, and a3, and then program will check that its valid triangle or not. If it’s valid triangle, then find the factorial of a1 with while loop, and find that a2 is a palindrome number or not.  If a2 is palindrome, then find the factorial of a2.

You must use the concepts of multiple inheritance in the program

Q#4                                                                                                                 7.5 Marks

Write a C++ program by using classes in which user enter  the number, program will reverse the number. After reversing the number, show the sum of all numbers. For example if number is 153, the after reverse it will be 351 and the sum will be 9. Now if the sum is a odd number, then show its odd number, otherwise show even number. Just even odd module must be implemented with operator overloading.

Further, you are not allowed to use for loop. You can use Do while loop.

### Paper 4 – Open Book Paper of Object-Oriented Programming in C++

 Course Title: Object-Oriented Programming Course Code: Confidential Discipline /Program :  MCS Total Marks:20 Time allowed: 12 Hours Instructor’s Name: Confidential Practical Paper

Q#1                                                                                                                             10 Marks

Write a C++ program by using classes to delete duplicate elements from an array? After duplicate elements removal, sort the array in descending order. After sorting the array, copy all sorted elements of the array1 into the array 2.

Further, you are not allowed to use for loop. You can use while loop, user define functions and multi level inheritance.

Q#2                                                                                                                             10 Marks

Write a C++ program by using classes to take the hours and minutes and the show that whether it is AM or PM by using the switch statements. Hours must be taken from nearest parent class, minutes must be taken virtually. If it’s AM then check that hours represent the prime number or not. Similarly if it’s PM, then check that minutes represent the strong number or not.

### Paper 5 – Open Book Conceptual Paper of Object-Oriented Programming in C++

 Course Title: Object-Oriented Programming Course Code: Confidential Discipline /Program :  MCS Total Marks:18 Time allowed: 12 Hours Instructor’s Name: Confidential Theory Paper

Q#1                                                                                                                             7.5 Marks

Write a C++  program by using classes to show the sum of array rows and columns.

You must write this program by using constructor and do while loop.

Q#2                                                                                                                 7.5 Marks

Write a C++ program by using classes  to find the greatest and lowest value from array. If the greatest value is greater then 100, then print “its my good luck”, otherwise print ”its my bad luck”.

You must use while loop and using the user define function. Further user define function must be accessible by some another friend class.

Q#3                                                                                                                 7.5 Marks

Write a C++ program by using classes  in which user enter the three angles a1, a2, and a3, and then program will check that its valid triangle or not. If it’s valid triangle, then find the factorial of a1 with while loop, and find that a2 is a palindrome number or not.  If a2 is palindrome, then find the factorial of a2.

You must use the concepts of multiple inheritance in the program

Q#4                                                                                                                 7.5 Marks

Write a C++ program by using classes in which user enter  the number, program will reverse the number. After reversing the number, show the sum of all numbers. For example if number is 153, the after reverse it will be 351 and the sum will be 9. Now if the sum is a odd number, then show its odd number, otherwise show even number. Just even odd module must be implemented with operator overloading.

Further, you are not allowed to use for loop. You can use Do while loop.

### Paper 6 – Open Book Logical Paper of Object-Oriented Programming in C++

 Course Title: Object-Oriented Programming Course Code: Confidential Discipline /Program :  MCS Total Marks:18 Time allowed: 12 Hours Instructor’s Name: Confidential Theory Paper

Q#1                                                                                                                                                                        6marks

Print star pattern in a rectangle  using while loop and by using the concept constructor and destructor

Q#2                                                                                                                                                                        6marks

Write a C++ program to check that a number is prime or not. If the number is prime then check that the prime number is a composite number or not. Write this program with the help of multi-level inheritance.

Q#3                                                                                                                                                                        6marks

Suppose you are developing a hospital management system in which the user enter the patient and doctor compulsory detail, and then patient checks that the doctor is available or not.

Redundancy is a big issue. So, write your program in C++ in such a way by using the inheritance that it reduce the redundancy.

You also need to draw the class diagram of the system.

### Paper 7 – Guess Paper of Object-Oriented Programming in C++

 Course Title: Object-Oriented Programming Course Code: Confidential Discipline /Program :  MCS Total Marks:18 Time allowed: 12 Hours Instructor’s Name: Confidential Theory Paper

Q#1                                                                                                                             7.5 Marks

You must write this program by using constructor and do while loop.

Write a C++ program by using classes in which user enter  the number, program will reverse the number. After reversing the number, show the sum of all numbers. For example if number is 153, the after reverse it will be 351 and the sum will be 9. Now if the sum is a odd number, then show its odd number, otherwise show even number. Just even odd module must be implemented with operator overloading.

Further, you are not allowed to use for loop. You can use Do while loop.

Q#2                                                                                                                 7.5 Marks

Write a C++ program by using classes  in which user enter the three angles a1, a2, and a3, and then the program will check that it’s valid triangle or not. If it’s the valid triangle, then find the factorial of a1 with while loop, and find that a2 is a palindrome number or not.  If a2 is a palindrome, then find the factorial of a2.

You must use the concepts of multiple inheritances in the program

Q#3                                                                                                                 7.5 Marks

Write a C++ program by using classes to find the greatest and lowest value from the array. If the greatest value is greater then 100, then print “its my good luck”, otherwise print ” it’s my bad luck”.

You must use for loop and using the user defined a function. Further user defines function must be accessible by some another friend class.

Q#4                                                                                                                 7.5 Marks

Write a C++  program by using 3 classes to print 3 rectangles of different sizes.

### Paper 8 – Guess Paper of Object-Oriented Programming in C++

Course Title:Object Oriented Programming
Total Marks:40
Time allowed: 1 Hour

Q.No.1.

Write a C++ program to display the area of a rectangle by using a class named ‘Area’ with two member functions. The first function named as ‘Dimension’ will takes the length and breadth of the rectangle as parameters and the second function named as ‘takeArea’ returns the area of the rectangle.  Assign proper data types to the data members of the classes. There should be two functions one to input/get data and the other to display the data. In main() create THREE objects of each class and assign data and then display the data of each object by calling the corresponding functions.                       [ 10 ]

Q.No.2.                                                                                                                                               [20]

a) Write a C++ Class having name StaticClass there should be three static data members (x,y,z). An initial value of 10 should be assigned to each data member. In default constructor x, y, and z should be incremented by 10, 20, and 30 respectively. Display this data using a static member function Display(). Create 5 objects and then display the data. Also write down the output (values of data members) on your answer sheet.

b) How private data of a class can be accessed from outside of the class? Briefly define friend function in C++ with a suitable concise example.

Q.No. 3. Define the following terms and write concise example where necessary.                             [10]

1. Constructor
2. Access specifiers and types
3. Data Abstraction along with programming example

[OBJECTIVE]

Subject: Object Oriented Programming

Time Allowed: 10 Minutes

Maximum Marks: 10

NOTE: Attempt this Paper on this Question Sheet only. Please encircle the correct option. Division of marks is given in front of each question. This Paper will be collected back after expiry of time limit mentioned above.

Part-I Encircle the right answer, cutting and overwriting is not allowed. (10)

1. A class must have a constructer
a) True b) False
2. Class level variable can be accessed without class object.
a) True b) False
3. If ptr is a pointer than cout << ptr will display the address of ptr.
a) True b) False
4. We can store a double pointer address in a double pointer.
a) True b) False
5. An entire structure may not be passed to a function as an argument.
a) True b) False
6. A class object consist of
a) Private/public members b) Attributes and functions
c) Either a or b d) one of them
7. Encapsulation refers to the combining of data and code into a
a) Class b) Program
c) Object d) None of them
8. If class has only parameterize constructer. Then what will be its default constructer?
a) Same parameterize constructer b) A constructer which takes no parameter
c) No default constructer. d) None of them.
9. It is good to make getter function
a) Const b) Public
c) public and const d) None of these
10. We can have multiple
a) Default constructer b) Parameterized constructer
c) Destructor d) None of these

[SUBJECTIVE]

Subject: Object Oriented Programming

Time Allowed: 2 Hours 45 Minutes

Maximum Marks: 50

NOTE: ATTEMPT THIS (SUBJECTIVE) ON THE SEPARATE ANSWER SHEET PROVIDED.

Q#1: Write down the output of the following code.

#include<iostream>

using namespace std;

class A{ int i_A;  public:   ACint x){ i_A = x; }            };

int main(){           A a;        cout<<“Hello”<<endl;    return 0;              }

Q#2: What is difference between a Class and Object?

Q#4: Write the output of the following code

#include<iostream>

using namespace std;

class A{ public:   A(){        cout << “A” << end1;      }

~A(){     cout << “~A” << end1;   }              };

class B: (){            public:   B(){        cout << “B” << end1;      }

~B(){      cout << ““B” << end1;    }              };

int main(){           B b;        return Q;             }