Undefined Behavior and Pitfalls interview questions
15 Undefined Behavior and Pitfalls questions from the C++ bank, written for Indian campus drives and tech interviews. Every question has a verified answer and an AI-tutor explanation on placd.
Free to start: the 2-minute IT readiness check — six questions and a result.
A.a program condition for which the standard imposes no requirements, permitting the compiler to assume it never happens and optimize accordingly
B.an alias still naming an object whose lifetime has ended, such as returning a reference to a local variable, making use of it invalid
C.writing or reading past the bounds of an array, corrupting adjacent memory and yielding undefined and often exploitable results
D.accessing memory through a pointer after the underlying allocation has been released, a common source of crashes and security flaws
Answer + AI explanation with Pro
2. Which term means: "a program condition for which the standard imposes no requirements, permitting the compiler to assume it never happens and optimize accordingly"?
Junior
A.Use after free
B.Undefined behavior
C.Buffer overflow
D.Dangling reference
Answer + AI explanation with Pro
3. Which statement is correct?
Junior
A.Undefined behavior — an alias still naming an object whose lifetime has ended, such as returning a reference to a local variable, making use of it invalid
B.Undefined behavior — an implicit conversion that may lose information, such as double to int, which brace initialization rejects at compile time
C.Undefined behavior — a program condition for which the standard imposes no requirements, permitting the compiler to assume it never happens and optimize accordingly
D.Undefined behavior — writing or reading past the bounds of an array, corrupting adjacent memory and yielding undefined and often exploitable results
Answer + AI explanation with Pro
4. What is Dangling reference?
Mid
A.an alias still naming an object whose lifetime has ended, such as returning a reference to a local variable, making use of it invalid
B.an implicit conversion that may lose information, such as double to int, which brace initialization rejects at compile time
C.a program condition for which the standard imposes no requirements, permitting the compiler to assume it never happens and optimize accordingly
D.accessing memory through a pointer after the underlying allocation has been released, a common source of crashes and security flaws
Answer + AI explanation with Pro
5. Which term means: "an alias still naming an object whose lifetime has ended, such as returning a reference to a local variable, making use of it invalid"?
Mid
A.Use after free
B.Narrowing conversion
C.Buffer overflow
D.Dangling reference
Answer + AI explanation with Pro
6. Which statement is correct?
Mid
A.Dangling reference — an alias still naming an object whose lifetime has ended, such as returning a reference to a local variable, making use of it invalid
B.Dangling reference — a program condition for which the standard imposes no requirements, permitting the compiler to assume it never happens and optimize accordingly
C.Dangling reference — accessing memory through a pointer after the underlying allocation has been released, a common source of crashes and security flaws
D.Dangling reference — an implicit conversion that may lose information, such as double to int, which brace initialization rejects at compile time
Answer + AI explanation with Pro
7. What is Narrowing conversion?
Mid
A.an implicit conversion that may lose information, such as double to int, which brace initialization rejects at compile time
B.an alias still naming an object whose lifetime has ended, such as returning a reference to a local variable, making use of it invalid
C.a program condition for which the standard imposes no requirements, permitting the compiler to assume it never happens and optimize accordingly
D.accessing memory through a pointer after the underlying allocation has been released, a common source of crashes and security flaws
Answer + AI explanation with Pro
8. Which term means: "an implicit conversion that may lose information, such as double to int, which brace initialization rejects at compile time"?
Mid
A.Narrowing conversion
B.Undefined behavior
C.Dangling reference
D.Use after free
Answer + AI explanation with Pro
9. Which statement is correct?
Mid
A.Narrowing conversion — accessing memory through a pointer after the underlying allocation has been released, a common source of crashes and security flaws
B.Narrowing conversion — an implicit conversion that may lose information, such as double to int, which brace initialization rejects at compile time
C.Narrowing conversion — a program condition for which the standard imposes no requirements, permitting the compiler to assume it never happens and optimize accordingly
D.Narrowing conversion — writing or reading past the bounds of an array, corrupting adjacent memory and yielding undefined and often exploitable results
Answer + AI explanation with Pro
10. What is Buffer overflow?
Senior
A.an implicit conversion that may lose information, such as double to int, which brace initialization rejects at compile time
B.an alias still naming an object whose lifetime has ended, such as returning a reference to a local variable, making use of it invalid
C.writing or reading past the bounds of an array, corrupting adjacent memory and yielding undefined and often exploitable results
D.a program condition for which the standard imposes no requirements, permitting the compiler to assume it never happens and optimize accordingly
Answer + AI explanation with Pro
11. Which term means: "writing or reading past the bounds of an array, corrupting adjacent memory and yielding undefined and often exploitable results"?
Senior
A.Undefined behavior
B.Buffer overflow
C.Dangling reference
D.Narrowing conversion
Answer + AI explanation with Pro
12. Which statement is correct?
Senior
A.Buffer overflow — a program condition for which the standard imposes no requirements, permitting the compiler to assume it never happens and optimize accordingly
B.Buffer overflow — writing or reading past the bounds of an array, corrupting adjacent memory and yielding undefined and often exploitable results
C.Buffer overflow — an alias still naming an object whose lifetime has ended, such as returning a reference to a local variable, making use of it invalid
D.Buffer overflow — an implicit conversion that may lose information, such as double to int, which brace initialization rejects at compile time
Answer + AI explanation with Pro
13. What is Use after free?
Mid
A.accessing memory through a pointer after the underlying allocation has been released, a common source of crashes and security flaws
B.a program condition for which the standard imposes no requirements, permitting the compiler to assume it never happens and optimize accordingly
C.writing or reading past the bounds of an array, corrupting adjacent memory and yielding undefined and often exploitable results
D.an implicit conversion that may lose information, such as double to int, which brace initialization rejects at compile time
Answer + AI explanation with Pro
14. Which term means: "accessing memory through a pointer after the underlying allocation has been released, a common source of crashes and security flaws"?
Mid
A.Dangling reference
B.Buffer overflow
C.Undefined behavior
D.Use after free
Answer + AI explanation with Pro
15. Which statement is correct?
Mid
A.Use after free — an implicit conversion that may lose information, such as double to int, which brace initialization rejects at compile time
B.Use after free — an alias still naming an object whose lifetime has ended, such as returning a reference to a local variable, making use of it invalid
C.Use after free — writing or reading past the bounds of an array, corrupting adjacent memory and yielding undefined and often exploitable results
D.Use after free — accessing memory through a pointer after the underlying allocation has been released, a common source of crashes and security flaws
Answer + AI explanation with Pro
Free to start
Start with a free readiness check
Sign up free for the 2-minute IT readiness check and a scored result. Answers, explanations and the AI tutor on every Undefined Behavior and Pitfalls question come with Pro.