# Past Papers of Object-Oriented Programming

Prof. Fazal Rehman Shamil

## 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.

## Sample Paper 1 of 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)

## Sample Paper 2 of 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.

### Sample 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.

### Sample 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.

### Sample 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.

### Sample 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.

### Sample 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. Prof.Fazal Rehman Shamil (Available for Professional Discussions)
1. Message on Facebook page for discussions,