0% found this document useful (0 votes)
21 views2 pages

Sameed CS304 Test Midterm

Uploaded by

zaeemfarooq125
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)
21 views2 pages

Sameed CS304 Test Midterm

Uploaded by

zaeemfarooq125
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/ 2

Object-Oriented Programming (CS304) Test

Total Marks: 100


Duration: 2 Hours

Section A: Multiple Choice Questions (MCQs)


(Each question carries 2 marks. Total 20 marks.)
1. What is the key feature of Object-Oriented Programming?
o a) Encapsulation

o b) Modularity

o c) Inheritance

o d) All of the above

2. Which of the following is NOT an example of a tangible object?


o a) Ali

o b) Car

o c) Time

o d) House

3. Which concept allows objects to behave differently based on their


type?
o a) Inheritance

o b) Encapsulation

o c) Polymorphism

o d) Abstraction

4. What is the purpose of a destructor in a class?


o a) Initialize objects

o b) Destroy objects

o c) Allocate memory

o d) All of the above

5. The process of restricting access to certain parts of an object is


called:
o a) Encapsulation
o b) Information Hiding

o c) Polymorphism

o d) Generalization

Section B: Short Questions


(Each question carries 5 marks. Total 40 marks.)
1. Define abstraction and explain its importance in object-oriented
programming with an example.
2. Differentiate between inheritance and composition with diagrams.
3. Explain encapsulation and how it achieves information hiding.
4. What are static members in a class? Provide an example in C++.
5. Write a short note on operator overloading and provide a code snippet
demonstrating the overloading of the + operator.
6. Discuss the role of "this" pointer in C++ programming.
7. How does polymorphism improve the flexibility of an object-oriented
program? Give a practical example.
8. Differentiate between shallow copy and deep copy with examples.

Section C: Programming Questions


(Each question carries 10 marks. Total 40 marks.)
1. Write a C++ program to demonstrate constructor overloading with at
least two constructors in a class.
2. Create a C++ program that uses inheritance to define a base class Shape
and derived classes Circle and Rectangle. Include a virtual function area() in
the base class and override it in the derived classes.
3. Write a C++ program to implement friend functions and explain their use
with a practical example.
4. Design a class Complex to represent complex numbers. Overload the +
operator to add two complex numbers and display the result.

You might also like