0% found this document useful (0 votes)
17 views6 pages

OODP question bank for unit 1 and unit 2

The document is a question bank containing multiple-choice questions and programming tasks related to Object-Oriented Programming (OOP) and C++. It includes questions on OOP principles, C++ syntax, and UML diagrams, along with programming assignments to implement various systems like a banking system, student management system, and library management system. The content is structured into parts, with Part A focusing on MCQs, and Parts B and C consisting of programming tasks and explanations.

Uploaded by

fakeidpayaluga
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)
17 views6 pages

OODP question bank for unit 1 and unit 2

The document is a question bank containing multiple-choice questions and programming tasks related to Object-Oriented Programming (OOP) and C++. It includes questions on OOP principles, C++ syntax, and UML diagrams, along with programming assignments to implement various systems like a banking system, student management system, and library management system. The content is structured into parts, with Part A focusing on MCQs, and Parts B and C consisting of programming tasks and explanations.

Uploaded by

fakeidpayaluga
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/ 6

OODP-QUESTION BANK

Multiple‐Choice Questions
1. Which of the following is NOT considered a core principle of Object-Oriented
Programming (OOP)?
A) Encapsulation
B) Inheritance
C) Abstraction
D) Compilation
2. Which of the following is NOT a primitive data type in C++?
A) int
B) bool
C) string
D) float
3. Find the output of the following C++ code snippet:
#include <iostream>
using namespace std;
int main() {
int a = 5, b = 10;
cout << a + b;
return 0;
}
A) 5
B) 10
C) 15
D) 20
4. In UML, a dashed arrow typically represents:
A) Dependency
B) Inheritance
C) Association
D) Aggregation
5. In C++, which keyword is used to inherit publicly from a base class?
A) inherits
B) public
C) extends
D) private
6. When is a constructor called in C++?
A) When an object is destroyed
B) When an object is created
C) When a class is declared
D) When a function is defined
7. How many constructors can a C++ class have?
A) Only one
B) Two
C) Multiple
D) Zero
8. Which of the following statements about operator overloading in C++ is TRUE?
A) Only member functions can be overloaded
B) Only non-member functions can be overloaded
C) Both member and non-member functions can be overloaded
D) Operators cannot be overloaded
9. In UML class diagrams, what does a solid diamond represent?
A) Inheritance
B) Aggregation
C) Composition
D) Association
10. Which access specifier allows derived classes to access base class members in C++?
A) private
B) protected
C) public
D) friend
11. Which of the following declarations defines a constant pointer in C++?
A) int *const ptr
B) const int *ptr
C) int const *ptr
D) const int *const ptr
12. Which keyword is used to define a namespace in C++?
A) package
B) module
C) namespace
D) system
13. Which of the following is NOT a valid access specifier in C++?
A) public
B) protected
C) private
D) secure
14. Which UML diagram is primarily used for representing the flow of control in a system?
A) Use Case Diagram
B) Activity Diagram
C) Class Diagram
D) Component Diagram
15. What is the primary purpose of the “friend” keyword in C++?
A) To enable inheritance
B) To allow external functions to access private members
C) To overload operators
D) To declare virtual functions
16. Which of the following best describes polymorphism in OOP?
A) The ability to encapsulate data
B) The ability to inherit methods
C) The ability to process objects differently based on their types
D) The ability to abstract classes
17. Which operator is used to access members of a structure in C++?
A) .
B) ->
C) ::
D) Both A and B
18. Which of the following correctly describes function overloading in C++?
A) Functions with the same name but different return types
B) Functions with different names but the same functionality
C) Functions with the same name and different parameter lists
D) Functions with the same name and identical parameter lists.

19. Which of the following is a valid way to write a single-line comment in C++?
A) // This is a comment
B) /*
C) %% This is a comment %%
D) ** This is a comment **

20. Which file extension is typically used for a C++ source file?
A) .c
B) .cpp
C) .cs
D) .java

21. Which library must be included to use input/output objects like cin and cout?
A) <stdio.h>
B) <stdlib.h>
C) <iostream>
D) <string>
22. What is the output of the following C++ code snippet?

#include <iostream>
using namespace std;
int main() { cout << "Hello, World!"; return 0; }
A) Hello, World!
B) "Hello, World!"
C) cout << "Hello, World!";
D) No output

23. Which of the following correctly declares an integer variable named num in C++?
A) int num;
B) integer num;
C) num int;
D) var num;

24. Which operator is used to access the value at the memory address stored in a pointer?
A) &
B) *
C) ->
D) %

25. How do you correctly create a pointer to an integer variable named var?
A) int* ptr = var;
B) int ptr = &var;
C) int* ptr = &var;
D) pointer int ptr = var;

PART B QUESTIONS:

1. Write a C++ program to implement a simple banking system.


Create a class BankAccount with private data members:
- accountNumber
- accountHolder
- balance
Include member functions to deposit money, withdraw money (ensuring that the
balance does not go negative), and display account details. The user should be allowed to
perform transactions.

2. Create a C++ class Student to manage student records.


The class should have private data members:
- name
- rollNumber
- marks for three subjects
Implement member functions to input student details, calculate the average marks,
determine the grade (e.g., A for 90–100, B for 80–89, etc.), and display the results.
3. Explain the features of OOPs with examples.
4. Design a Use Case diagram for an online food ordering system.
The diagram should include actors such as:
- Customer
- Restaurant
- Delivery Person
And use cases like:
- Order Food
- Make Payment
- Track Order

5. Write a C++ program to implement a Library Management System.


Create a class Book with attributes:
- title
- author
- ISBN
Implement member functions to add a new book, display book details, and search for a
book by title.
6. Explain the types of relationships in UML Class diagrams.

7. Create a C++ class Matrix to perform matrix addition.


The class should include member functions to:
- Input two matrices (for example, 2×2 matrices)
- Add the matrices
- Display the resulting matrix

8. Design a Use Case diagram for a hotel reservation system.


The diagram should depict actors such as:
- Guest
- Receptionist
- Manager
And use cases like:
- Book Room
- Check-In/Check-Out
- Process Payment

9. Write a C++ program to demonstrate inheritance.


Create a base class Shape with a virtual function area() and derive two classes:
- Circle (calculating area using radius)
- Rectangle (calculating area using length and breadth)
Each derived class should override the area() function and display the computed area
based on user input.
10. Explain public and private types of access specifiers and implement the same with
suitable examples.
PART C Questions:

1. Implement a C++ code for a customer class for an e-commerce application.


Create a class Customer with attributes: customer ID, name, and email. Include member
functions to input customer details, update the email address, and display customer
information. Also, illustrate a class diagram for this application.

2. Write a C++ program that simulates a Student Management System.


Create a class called Student with attributes such as name, roll number, and marks.
Implement both default and parameterized constructors to initialize student objects and
display their details.

3. Develop a C++ program to implement a Library System.


Create a class Book with attributes: title, author, and ISBN. Implement functions to add a
new book, remove a book, and display all available books. Also, include a class diagram
for the system.

4. Create a C++ program that utilizes function overloading to perform arithmetic operations.
Implement overloaded functions to handle addition, subtraction, and multiplication for
both integers and floating-point numbers. The functions should differ by the number and
types of parameters.

5. Write a C++ program to simulate a Vehicle Management System.


Create a base class Vehicle with attributes such as model and speed, and derive two
classes: Car and Bike with additional specific attributes. Override a function to display
detailed vehicle information. Also, include a class diagram.

6. Implement a C++ program to simulate a Restaurant Order Management System.


Create a class Order with attributes such as order ID, table number, and total amount.
Include member functions to take order details, calculate the bill, and display the order
summary. Also, illustrate a class diagram for the system.

7. Create a C++ program to simulate a Simple Calculator using function overloading.


Implement overloaded functions to perform addition, subtraction, multiplication and
division. Ensure that the functions can handle different parameter types (e.g., integers and
doubles).

You might also like