Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.

Unit 2 MCQs Pointers, Reference Variables, Arrays and String Concepts

CSE202 — Object Oriented Programming 50 questions. Pick an option to check it.

Read the notes

0 of 50 answered 0 right 0 wrong , 50 left

  1. Question 1 of 50

    Which of the following best describes a void pointer in C++?

  2. Question 2 of 50

    If 'ptr' is an integer pointer holding the address 1000, and the size of an integer is 4 bytes, what will be the address after executing 'ptr + 1'?

  3. Question 3 of 50

    Which operator is used to access the value pointed to by a pointer?

  4. Question 4 of 50

    What is a pointer to a pointer?

  5. Question 5 of 50

    Which scenario results in a 'Dangling Pointer'?

  6. Question 6 of 50

    What is a 'Wild Pointer'?

  7. Question 7 of 50

    Which keyword is used in C++11 and later to represent a null pointer safely?

  8. Question 8 of 50

    When a class contains a pointer member, what specific member function is often required to prevent shallow copy issues?

  9. Question 9 of 50

    Which operator is used to access members of a class through a pointer to an object?

  10. Question 10 of 50

    The 'this' pointer is accessible:

  11. Question 11 of 50

    What is the type of the 'this' pointer in a non-const member function of class X?

  12. Question 12 of 50

    How do you declare an array of 10 objects of class 'Student'?

  13. Question 13 of 50

    When declaring an array of objects, which constructor is invoked for each element?

  14. Question 14 of 50

    Which header file is required to use the Standard C++ string class?

  15. Question 15 of 50

    Which operator is used to concatenate two C++ string objects?

  16. Question 16 of 50

    What is the difference between string::length() and string::size()?

  17. Question 17 of 50

    Which function is used to convert a C++ string object to a C-style string (char*)?

  18. Question 18 of 50

    Which string member function checks if the string is empty?

  19. Question 19 of 50

    How does a reference variable differ from a pointer regarding initialization?

  20. Question 20 of 50

    Can a reference variable be reassigned to refer to a different variable after initialization?

  21. Question 21 of 50

    Which of the following is valid syntax for declaring a reference to an integer 'a'?

  22. Question 22 of 50

    In a 2D array declaration 'int arr[3][4]', what does '3' represent?

  23. Question 23 of 50

    How are elements of a multidimensional array stored in memory in C++?

  24. Question 24 of 50

    Which is the correct syntax to define a pointer to a data member of class 'Test' of type int?

  25. Question 25 of 50

    Which operator is used to access a data member using a pointer to data member and an object instance?

  26. Question 26 of 50

    If string s = "Hello";, what does s.at(1) return?

  27. Question 27 of 50

    What happens if you try to modify a string literal assigned to a char* in C++? (e.g., char* p = "Hello"; p[0] = 'X';)

  28. Question 28 of 50

    Which modifier function appends a string to the end of the current string object?

  29. Question 29 of 50

    What does the following pointer arithmetic expression result in? void *p; p++;

  30. Question 30 of 50

    When passing a multidimensional array to a function, which dimension must be specified?

  31. Question 31 of 50

    Can a reference variable accept a NULL value?

  32. Question 32 of 50

    Given int x = 10; int *p = &x; int **q = &p;, what does **q access?

  33. Question 33 of 50

    Which statement correctly deletes an array of objects allocated with new?

  34. Question 34 of 50

    What is the purpose of the getline(cin, str) function?

  35. Question 35 of 50

    In string::npos, what does npos usually represent?

  36. Question 36 of 50

    Which string function replaces a part of the string with another string?

  37. Question 37 of 50

    If a class has a constant member function, can it modify data members pointed to by the this pointer?

  38. Question 38 of 50

    What is the output of comparing two string objects using ==?

  39. Question 39 of 50

    Which allows a pointer to be modified but the data it points to cannot be changed?

  40. Question 40 of 50

    What does int * const ptr define?

  41. Question 41 of 50

    Which operator allows accessing members of an object using a pointer to a member function (func_ptr) and a pointer to an object (obj_ptr)?

  42. Question 42 of 50

    Why is string s; cin >> s; potentially problematic for reading names like "New York"?

  43. Question 43 of 50

    How do you access the element at row 1, column 2 of a 2D array named matrix?

  44. Question 44 of 50

    What happens when you assign one C++ string object to another (e.g., str1 = str2)?

  45. Question 45 of 50

    Can an array be a data member of a class?

  46. Question 46 of 50

    Which string method returns a substring?

  47. Question 47 of 50

    If p is a null pointer, what is the result of delete p;?

  48. Question 48 of 50

    What is the specific issue called when delete is forgotten for memory allocated with new?

  49. Question 49 of 50

    Which of the following correctly declares a pointer to a function that takes an int and returns void?

  50. Question 50 of 50

    In pointer arithmetic, subtracting two pointers of the same type results in:

That's unit 2

Answer a few questions and your score shows up here.