Unit 1: C++ Programming Basics and Functions - Subjective Questions

CSE202 — Object Oriented Programming • Practice Questions with Detailed Answers

20 questions

1

Define object-oriented programming (OOP). Explain its fundamental concepts and name some commonly used OOP languages.

2

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

3

Explain how cin and cout are used to read and write data in C++. Also describe the role of the extraction and insertion operators.

4

Describe the important features of C++ input/output streams. How do stream states help in handling input errors?

5

Explain the creation of a class and its objects in C++. How are public and private class members accessed?

6

Distinguish among structures, unions, enumerations, and classes in C++.

7

Compare inline and non-inline member functions. Show how each can be defined in C++.

8

What are static data members and static member functions? Explain their properties with a suitable C++ example.

9

Explain functions with default arguments in C++. State the rules and possible ambiguities associated with default arguments.

10

Define an inline function. Discuss its advantages, limitations, and the circumstances in which the compiler may avoid inline expansion.

11

What are manipulator functions in C++? Explain commonly used manipulators with examples.

12

Explain function overloading in C++. How does the compiler resolve overloaded calls, and what combinations cannot be used to overload functions?

13

Describe the scope rules of C++. Explain local, global, class, namespace, and block scope, and show how the scope-resolution operator is used.

14

What is a friend function? Explain its characteristics, benefits, and risks with an example.

15

Explain a friend class in C++. How does it differ from a friend function, and what rules govern friendship?

16

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

17

Differentiate among call by value, call by address, and call by reference in C++. Give an example of each and discuss their effects on the caller's variables.

18

Explain recursion using an ordinary function. Write a recursive function for factorial and trace the evaluation of factorial(4).

19

Describe recursion using a member function. Design a class containing a recursive function to calculate the sum of the first natural numbers.

20

Design a C++ class named BankAccount that demonstrates encapsulation, console input/output, an inline member function, a non-inline member function, and a static data member.