Unit 1: Principles of OOP and C++ Essentials - Subjective Questions

CAP455 — Object Oriented Programming Using C++ • Practice Questions with Detailed Answers

20 questions

1

Compare the procedural programming paradigm with the object-oriented programming paradigm.

2

Explain input and output streams in C++ with suitable examples.

3

Define a class and an object in C++. Explain their relationship and the role of access specifiers.

4

Describe how member functions are defined inside and outside a C++ class. Illustrate your answer with a program.

5

Distinguish between a structure and a union in C++. Include their memory behavior and typical uses.

6

What is an enumeration in C++? Compare unscoped enumerations with scoped enumeration classes.

7

Explain static data members of a class. How are they declared, defined, and accessed?

8

What is a static member function? State its properties and limitations.

9

Explain user-defined functions in C++. Describe function declaration, definition, call, parameters, and return value.

10

Define an inline function. Discuss its advantages, limitations, and difference from a preprocessor macro.

11

What is a friend function in C++? Explain its declaration, use, and effect on encapsulation.

12

Explain the concept of a friend class. How does it differ from a friend function?

13

Define a reference variable in C++. Explain its initialization, uses, and important restrictions.

14

Differentiate among call by value, call by address, and call by reference in C++.

15

Write and explain C++ functions that swap two integers using call by value, call by address, and call by reference.

16

Define recursion. Explain the base case, recursive case, and role of the call stack.

17

Develop a recursive C++ function to calculate factorial and trace its execution for .

18

Compare recursion and iteration. State the advantages and disadvantages of each technique.

19

Describe formatted input/output and stream-state handling in C++.

20

Design a C++ class that demonstrates classes and objects, an enumeration class, a static data member, a static member function, a friend function, and reference parameters. Explain the design.