Unit 2: Handling Pointers, Arrays and String - Subjective Questions

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

20 questions

1

Explain the differences between pointer variables and reference variables in C++.

2

What is a void pointer? Explain its declaration, use, and limitations with an example.

3

Explain pointer arithmetic in C++. Derive the addresses obtained when an integer pointer is incremented.

4

What is a pointer to pointer? Explain its declaration and use with a suitable C++ example.

5

Define dangling pointer, wild pointer, and null pointer. Distinguish among them and explain how each can be avoided.

6

Explain null pointer assignment in modern C++. Why is nullptr preferred over 0 and NULL?

7

Describe how pointers can be declared as class data members. Explain their initialization and memory-management requirements.

8

Explain pointers to objects in C++ with syntax for object creation, member access, and dynamic allocation.

9

What is the this pointer? Explain its characteristics and uses inside a class.

10

Explain a pointer to a data member in C++. Give its declaration and demonstrate how it is used.

11

Explain the declaration, initialization, and processing of one-dimensional and multidimensional arrays in the main() function.

12

Describe how a multidimensional array can be declared and processed inside a class.

13

Explain row-major storage of a two-dimensional C++ array and derive the address formula for an element.

14

What is an array of objects? Explain its declaration, initialization, and processing with an example.

15

Explain the standard C++ string class and compare it with a traditional character array.

16

Describe different ways of defining and assigning string objects in C++.

17

Explain the important modifiers of the C++ string class, such as append, insert, erase, replace, and clear.

18

Explain commonly used non-modifying operations of the C++ string class, including length, comparison, searching, and substring extraction.

19

Compare static arrays and dynamically allocated arrays in C++. Discuss their memory allocation, size, and deallocation.

20

Explain how pointers and arrays are related in C++. Include array traversal using pointer arithmetic and state important differences.