11 Sep 100 C++ MCQ (Multiple Choice Questions) with Answers
Show Answer
2) Which standard output stream is used in C++ to display text?
Show Answer
3) Which header file is needed to use std::cout and std::cin?
Show Answer
4) What is the standard extension of a C++ source code file?
Show Answer
5) Which operator is used for input stream insertion in C++?
Show Answer
6) Which operator is used for scope resolution in C++?
Show Answer
7) Which keyword is used to define a class in C++?
Show Answer
8) What is the default access modifier for members of a class in C++?
Show Answer
9) What is the default access specifier for members of a struct in C++?
Show Answer
10) Which keyword is used to allocate memory dynamically in C++?
Show Answer
11) Which operator is used to deallocate dynamic memory allocated with new?
Show Answer
12) Which keyword is used to pass a parameter by reference without creating a copy?
Show Answer
13) What function is called automatically when an object is created?
Show Answer
14) What symbol precedes the name of a destructor function in C++?
Show Answer
15) Can a constructor be overloaded in C++?
Show Answer
16) Can a destructor be overloaded in C++?
Show Answer
17) Which feature allows defining multiple functions with the same name but different parameters?
Show Answer
18) What is function overriding?
Show Answer
19) Which keyword is used to make a method support dynamic binding / runtime polymorphism?
Show Answer
20) What is a class containing at least one pure virtual function called?
Show Answer
21) What is the syntax for declaring a pure virtual function in C++?
Show Answer
22) Which operator cannot be overloaded in C++?
Show Answer
23) Which of the following operators CANNOT be overloaded?
Show Answer
24) Which keyword is used to grant a non-member function access to private members of a class?
Show Answer
25) What pointer refers to the current invoking instance inside a member function?
Show Answer
26) Which type of inheritance allows a derived class to inherit from multiple base classes?
Show Answer
27) What problem arises when a class inherits from two classes that both inherit from the same base class?
Show Answer
28) Which keyword resolves the Diamond Problem when declaring base class inheritance?
Show Answer
29) What is the output of sizeof(bool) in standard C++?
Show Answer
30) Which keyword is used to define template functions or classes in C++?
Show Answer
31) Which exception handling keyword is used to inspect a code block for errors?
Show Answer
32) Which keyword is used to signal the occurrence of an exception?
Show Answer
33) Which block handles an exception thrown from a try block?
Show Answer
34) What does STL stand for in C++?
Show Answer
35) Which container in STL represents a dynamic contiguous array?
Show Answer
36) Which STL container is implemented as a doubly linked list?
Show Answer
37) Which STL container stores unique elements in sorted order?
Show Answer
38) Which header file is required to use std::vector?
Show Answer
39) What method returns the number of elements in a std::vector?
Show Answer
40) What method adds an element to the end of a std::vector?
Show Answer
41) What is the output of 7 / 2 in C++ integer arithmetic?
Show Answer
42) What is the result of 7 % 2 in C++?
Show Answer
43) Which keyword is used to prevent modification of a variable’s value?
Show Answer
44) What keyword was introduced in C++11 for automatic type deduction?
Show Answer
45) Which value represents a null pointer constant introduced in C++11?
Show Answer
46) What does RAII stand for in C++ programming?
Show Answer
47) Which smart pointer provides exclusive ownership of an object?
Show Answer
48) Which smart pointer uses reference counting to manage shared ownership?
Show Answer
49) Which header file is required for smart pointers like std::unique_ptr?
Show Answer
50) What keyword suggests to the compiler to inline a function to reduce call overhead?
Show Answer
51) What type of casting is used for conversion between related class pointer types at runtime?
Show Answer
52) Which cast operator removes the const qualification from a variable?
Show Answer
53) Which cast is used for low-level bitwise reinterpretation of memory addresses?
Show Answer
54) What is the scope of a variable declared with static inside a function?
Show Answer
55) How do you declare a constant expression evaluated at compile-time in C++11?
Show Answer
56) What is an anonymous inline function introduced in C++11 called?
Show Answer
57) In a lambda expression [=]() { … }, what does [=] mean?
Show Answer
58) In a lambda expression [&]() { … }, what does [&] mean?
Show Answer
59) What is the type of string literals like “Hello” in C++?
Show Answer
60) Which standard library header provides std::string?
Show Answer
61) Which method converts a std::string object to a C-style null-terminated string?
Show Answer
62) What does cin.get() do?
Show Answer
63) Which function reads an entire line including spaces into a std::string?
Show Answer
64) What happens if delete is used on a memory allocated with new[] (array allocation)?
Show Answer
65) What is the result of dereferencing a nullptr?
Show Answer
66) What is a pointer pointing to memory that has been deallocated called?
Show Answer
67) What is an uninitialized pointer called?
Show Answer
68) What class stream is used for reading from files in C++?
Show Answer
69) What class stream is used for writing to files in C++?
Show Answer
70) Which header file is required for file I/O operations in C++?
Show Answer
71) What mode flag in fstream appends output to the end of a file?
Show Answer
72) Which keyword specifies that a class member cannot be modified inside a const member function?
Show Answer
73) What key property allows mutable data members to be modified?
Show Answer
74) What is the scope of protected members of a base class?
Show Answer
75) When a class inherits a base class publicly (class Derived : public Base), how do protected base members behave?
Show Answer
76) What happens to public members when inheriting privately (class Derived : private Base)?
Show Answer
77) What operator is used to access members using an object reference or instance?
Show Answer
78) What operator is used to access members using an object pointer?
Show Answer
79) What feature allows a constructor to be called with a single argument without implicit type conversion?
Show Answer
80) What C++11 keyword prevents a class from being inherited or a virtual function from being overridden?
Show Answer
81) What C++11 keyword explicitly specifies that a method overrides a base class virtual function?
Show Answer
82) What is the size of a empty class in C++?
Show Answer
83) Why does an empty class have a non-zero size in C++?
Show Answer
84) What is VTABLE in C++?
Show Answer
85) What hidden pointer inside an object points to the VTABLE?
Show Answer
86) When is the VTABLE resolution performed?
Show Answer
87) What is copy constructor signature for class A?
Show Answer
88) What occurs if a copy constructor takes parameter by value (A(A obj)) instead of reference?
Show Answer
89) What type of copy duplicates pointer addresses rather than pointing to new memory allocations?
Show Answer
90) What type of copy allocates new memory and duplicates actual data values?
Show Answer
91) What rule states that if a class requires a custom destructor, copy constructor, or copy assignment operator, it likely needs all three?
Show Answer
92) With C++11 move semantics, Rule of Three expanded into which rule?
Show Answer
93) Which operator was introduced in C++11 to support move semantics by referencing rvalues?
Show Answer
94) Which standard library function converts an lvalue to an rvalue to enable moving?
Show Answer
95) Which header file provides std::move and std::forward?
Show Answer
96) Which header file contains general algorithms like std::sort, std::find, and std::reverse?
Show Answer
97) What is the average time complexity of std::sort() in STL?
Show Answer
98) Which namespace contains all standard C++ library components?
Show Answer
99) Which keyword allows using components of a namespace without qualifying them explicitly?
Show Answer
100) What is the output of sizeof(int*) on a 64-bit operating system architecture?
Show Answer
No Comments