Question Bank Oop
Question Bank Oop
Functions, Virtual Attribute and Inheritance, Virtual Functions and Hierarchy, Pure Virtual Functions, Early
vs. Late Binding, Run-Time Type ID and Casting Operators: RTTI, Casting Operators, Dynamic Cast.
Part – A (Short Answer Questions)
1. What is the purpose of access control in C++ inheritance? Remember CO1, CO2
2. Explain the difference between public, private, and Remember CO1, CO2
protected inheritance.
3.. What is the significance of protected inheritance? Remember CO1, CO2
4. Define multiple inheritance in C++. Remember CO1, CO2
5. How are protected members of a base class accessed in Remember CO1, CO2
derived classes?
6. Discuss the advantages and drawbacks of multiple Remember CO1, CO2
inheritance.
7. How are constructors and destructors inherited in C++? Remember CO1, CO2
8. In what order are constructors and destructors called in a Remember CO1, CO2
derived class?
9. What are the different ways to grant access to base class Understand CO1, CO2
members in derived classes?
10. Explain the use of friend functions in accessing base class Understand CO1, CO2
members.
11. What is a virtual base class in C++? Understand CO1, CO2
12. How does a virtual base class address the diamond Understand CO1, CO2
problem in multiple inheritance?
13. Define virtual functions in C++. Understand CO1, CO2
14. Explain the significance of virtual functions in achieving Understand CO1, CO2
polymorphism.
15. What is a pure virtual function in C++? Understand CO1, CO2
16. What is Run-Time Type Identification (RTTI) in C++? Understand CO1, CO2
Part – B (Long Answer Questions)
1. Explain the concept of access control in inheritance. Remember CO1, CO2
Provide examples demonstrating the use of public, private,
and protected inheritance in C++.
2. Discuss the implications of changing the access specifier Remember CO1, CO2
when inheriting a base class privately or publicly in C++.
How does it affect member accessibility in derived
classes?
3. Describe the role of protected members in C++ Understand CO1, CO2
inheritance. Provide examples to illustrate how protected
members are accessible in derived classes but not outside
the inheritance hierarchy.
4. Discuss scenarios where using protected inheritance is Remember CO1, CO2
preferred over public or private inheritance. Provide real-
world examples to support your explanation
5. Discuss the behavior of constructors and destructors in Remember CO1, CO2
C++ inheritance. Explain how constructors and destructors
are invoked in derived classes.
6. Explain the importance of invoking base class constructors Understand CO1, CO2
explicitly in derived class constructors. Provide examples
to illustrate the constructor chaining process.
7. Discuss various methods for granting access to base class Understand CO1, CO2
members from derived classes in C++. Compare and
contrast using friend functions, protected members, and
inheritance for accessing base class members.
8. Explain the concept of virtual base classes in C++. Discuss Remember CO1, CO2
how virtual base classes address the diamond problem in
multiple inheritance.
9. Define virtual functions in C++. Discuss how virtual Understand CO1, CO2
Approved by AICTE, Ministry of HRD, Govt. of India ISO 9001:2015, ISO 14001:2015, ISO 50001:2018
Affiliated: VMSB Uttarakhand Technical University Sri Dev Suman Uttarakhand University Uttarakhand Board of Technical Education
in C++?
8. What are the available options for exception handling in Understand CO1, CO3, CO4
C++?
9. Explain the purpose and behavior of std::terminate() and Remember CO1, CO3, CO4
std::unexpected() in C++ exception handling.
10. What is the role of the std::uncaught_exception() Understand CO1, CO3, CO4
function in C++?
11. Differentiate between the std::exception and Understand CO1, CO3, CO4
std::bad_exception classes in C++.
12. How do you apply exception handling in C++? Provide an Remember CO1, CO3, CO4
example illustrating its usage.
Part - B (Long Answer Questions)
1. Explain the concept of generic functions in C++ using Remember CO1, CO3, CO4
templates. Provide examples demonstrating the creation
and use of generic functions.
2. Discuss the versatility and power of templates in C++. Remember CO1, CO3, CO4
Explain how templates enable the creation of generic
algorithms and data structures.
3. Describe the process of applying generic functions in real- Understand CO1, CO3, CO4
world scenarios. Provide examples where the use of
generic functions simplifies code and improves code reuse.
4. Define generic classes in C++ using templates. Explain the Understand CO1, CO3, CO4
syntax for declaring and implementing generic classes.
5. Discuss the significance of the typename and export Understand CO1, CO3, CO4
keywords in template declarations. Explain when and how
they are used in template programming.
6. Identify the advantages and limitations of using templates Understand CO1, CO3, CO4
in C++ programming. Discuss scenarios where templates
are particularly useful.
7. Describe the fundamentals of exception handling in C++. Understand CO1, CO3, CO4
Explain the purpose of exception handling and how it
differs from traditional error-handling mechanisms.
8. Explain the purpose and behavior of the terminate() and Understand CO1, CO3, CO4
unexpected() functions in C++ exception handling.
Discuss their role in handling uncaught exceptions and
unexpected program termination.
9. Define the std::exception and std::bad_exception classes in Understand CO1, CO3, CO4
C++. Discuss their hierarchy and the types of exceptions
they represent.
Part – C (Problem Solving and Critical Thinking)
1. Design a C++ template function that sorts an array of any Apply CO1, CO3, CO4
data type in ascending order using the quicksort algorithm.
Handle exceptions for invalid input array or unsupported
data types.
2. Develop a C++ template class that represents a generic Apply CO1, CO3, CO4
stack data structure. Implement methods for push, pop,
and top operations, ensuring exception safety and proper
error handling.
3. Create a C++ program that utilizes templates to implement Apply CO1, CO3, CO4
a generic calculator capable of performing arithmetic
operations on operands of any data type. Handle
exceptions for division by zero and invalid input.
UNIT-V
I/O System Basics:
Approved by AICTE, Ministry of HRD, Govt. of India ISO 9001:2015, ISO 14001:2015, ISO 50001:2018
Affiliated: VMSB Uttarakhand Technical University Sri Dev Suman Uttarakhand University Uttarakhand Board of Technical Education
Streams and Formatted 1/O. File I/O: File Classes, File Operations. Namespaces: Namespaces, std
Namespace. Standard Template Library: Overview, Container Classes, General Theory of Operation, Lists,
string Class, Final Thoughts on STL.
Part - A (Short Answer Questions)
1. What are streams in C++ I/O system? Understand CO1, CO4
2. Explain the difference between formatted and unformatted Understand CO1, CO4
I/O.
3. How do you perform formatted output in C++ using Understand CO1, CO4
streams?
4. What are file classes in C++? Understand CO1, CO4
5. List some common file operations in C++. Understand CO1, CO4
6. How do you open a file for reading and writing in C++? Understand CO1, CO4
7. Define namespaces in C++. Understand CO1, CO4
8. Explain the significance of the std namespace in C++. Understand CO1, CO4
9. Provide an overview of the Standard Template Library Understand CO1, CO4
(STL).
10. Name three container classes provided by the STL. Understand CO1, CO4
11. How is a list different from an array in the context of the Understand CO1, CO4
STL?
Part - B (Long Answer Questions)
1. Define the concept of a C++ namespace. Provide an Understand CO1, CO4
example of how namespaces help avoid naming conflicts
in C++ programs.
2. Explain the purpose of the ifstream and ofstream classes in Understand CO1, CO4
C++ file I/O. Give examples of how these classes are used
to read from and write to files.
3. Describe the key features of a doubly linked list data Understand CO1, CO4
structure. Discuss its advantages and disadvantages
compared to other types of lists.
4. Discuss the significance of streams in C++ programming. Understand CO1, CO4
How do streams facilitate input and output operations in
C++? Provide examples to illustrate your points.
5. Explain the difference between pass-by-value and pass-by- Understand CO1, CO4
reference in C++ function arguments. Discuss the
implications of each method and when you might choose
one over the other.
6. Describe the purpose of the std::string class in C++. How Understand CO1, CO4
does it differ from C-style strings? Provide examples to
demonstrate its usage and advantages.
Part – C (Problem Solving and Critical Thinking)
1. Write a C++ program to create a new text file and write Apply CO1, CO4, CO5
some text into it.
2. Write a C++ program to count the number of lines in a text Apply CO1, CO4, CO5
file.
3. Write a C++ program to append new data to an existing Apply CO1, CO4, CO5
text file.
4. Write a C++ program to search for a specific string in a Apply CO1, CO4, CO5
text file and display its line number(s).
HOD, CSE