PRACTICE • LEARN • GROW
Module 11 Final Quiz: Modern C++ (11 / 14 / 17 / 20) MCQs
Solve topic-wise placement questions and improve your skills.
Module 11 Final Quiz: Modern C++ (11 / 14 / 17 / 20) Progress
0 of 12 completed
0%
Topic Track
You are viewing MCQs in preview mode. Log in to select options, submit answers, and track your progress.
Log In to Answer
1
What does the 'auto' keyword do when declaring a variable in modern C++ (C++11)?
A.
Makes the variable dynamic like in Python
B.
Instructs the compiler to deduce the variable's type at compile-time from its initialization expression
C.
Allocates the variable automatically on the heap
D.
Makes the variable accessible across all files
Explanation & Key
Correct Answer:
2
What are the four components of a C++ lambda expression syntax?
A.
[capture] (parameters) -> return_type { body }
B.
def lambda(parameters) -> { body }
C.
(parameters) : return_type => [capture]
D.
lambda [parameters] { body }
Explanation & Key
Correct Answer:
3
What does '[=]' in a lambda capture clause mean?
A.
Capture all surrounding variables by reference
B.
Capture all used surrounding local variables by value (read-only copy)
C.
Assign equal memory to all variables
D.
Compare all variables for equality
Explanation & Key
Correct Answer:
4
What problem do Move Semantics (introduced in C++11) solve?
A.
They allow variables to move between CPU cores
B.
They eliminate expensive deep-copies of heap resources by transferring buffer pointers directly from temporary/rvalue objects
C.
They move code into GPU memory
D.
They automatically delete memory after 5 seconds
Explanation & Key
Correct Answer:
5
What does 'std::move(x)' actually do?
A.
It physically moves the bytes of x in RAM
B.
It unconditionally casts x to an rvalue reference (T&&), signaling that x can safely be moved from
C.
It frees the memory of x
D.
It transfers x to another thread
Explanation & Key
Correct Answer:
6
What state is an object left in after being moved from (e.g. b = std::move(a))?
A.
It is permanently deleted and accessing it crashes
B.
It is in a 'valid but unspecified state' (e.g. string/vector is typically empty, but safe to assign to or destroy)
C.
It contains duplicate data of b
D.
Its address is reset to 0x0
Explanation & Key
Correct Answer:
7
What is the syntax of a range-based for loop in C++11?
A.
for (item in container) {}
B.
for (auto item : container) {}
C.
foreach (container as item) {}
D.
loop (container -> item) {}
Explanation & Key
Correct Answer:
8
Why should you use 'for (const auto& item : container)' when iterating over large objects?
A.
To avoid making an expensive copy of each element on every iteration while preventing accidental modification
B.
Because range-based for loops cannot work with value copies
C.
To sort the container automatically
D.
To enable multithreaded looping
Explanation & Key
Correct Answer:
9
What feature introduced in C++17 allows unpacking a pair, tuple, or struct into named variables in one statement?
A.
Type Aliases
B.
Structured Bindings (e.g. auto [key, value] = pair;)
C.
Deconstruction Functions
D.
Tuple Unpacker
Explanation & Key
Correct Answer:
10
What is the output of the following C++17 snippet?
map m = {{"apples", 10}};
for (auto& [fruit, count] : m) {
cout << fruit << ":" << count;
}
A.
apples:10
B.
apples
C.
10
D.
Compilation Error
Explanation & Key
Correct Answer:
11
What does 'constexpr' signify when applied to a function or variable?
A.
The variable is stored in flash memory
B.
The expression is evaluated at compile-time whenever possible, guaranteeing zero runtime cost
C.
The function cannot take parameters
D.
The function runs in constant O(1) time
Explanation & Key
Correct Answer:
12
What is 'nullptr' in C++11 and why is it preferred over NULL or 0?
A.
nullptr is an integer 0
B.
nullptr is a strongly-typed pointer literal of type std::nullptr_t, avoiding ambiguous overloads between integer 0 and pointer types
C.
nullptr frees memory automatically
D.
nullptr can only be used with smart pointers
Explanation & Key
Correct Answer:
Question Palette
Answered
Current
Not Attempted
Wrong