15 Memory and RAII 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 reference-counted smart pointer that deletes its managed object only when the last owner sharing the count is destroyed
B.allocates an object on the free store and runs its constructor, returning a pointer that must later be released to avoid a leak
C.a non-owning observer of a shared resource that does not affect the reference count and is used to break ownership cycles
D.a technique that ties resource acquisition to object construction and release to destruction, guaranteeing cleanup when scope exits even on exceptions
Answer + AI explanation with Pro
2. Which term means: "allocates an object on the free store and runs its constructor, returning a pointer that must later be released to avoid a leak"?
Junior
A.std::weak_ptr
B.std::shared_ptr
C.new expression
D.std::unique_ptr
Answer + AI explanation with Pro
3. Which statement is correct?
Junior
A.new expression — allocates an object on the free store and runs its constructor, returning a pointer that must later be released to avoid a leak
B.new expression — a non-owning observer of a shared resource that does not affect the reference count and is used to break ownership cycles
C.new expression — a technique that ties resource acquisition to object construction and release to destruction, guaranteeing cleanup when scope exits even on exceptions
D.new expression — a reference-counted smart pointer that deletes its managed object only when the last owner sharing the count is destroyed
Answer + AI explanation with Pro
4. What is RAII?
Junior
A.allocates an object on the free store and runs its constructor, returning a pointer that must later be released to avoid a leak
B.a non-owning observer of a shared resource that does not affect the reference count and is used to break ownership cycles
C.a reference-counted smart pointer that deletes its managed object only when the last owner sharing the count is destroyed
D.a technique that ties resource acquisition to object construction and release to destruction, guaranteeing cleanup when scope exits even on exceptions
Answer + AI explanation with Pro
5. Which term means: "a technique that ties resource acquisition to object construction and release to destruction, guaranteeing cleanup when scope exits even on exceptions"?
Junior
A.std::unique_ptr
B.RAII
C.std::weak_ptr
D.std::shared_ptr
Answer + AI explanation with Pro
6. Which statement is correct?
Junior
A.RAII — a non-owning observer of a shared resource that does not affect the reference count and is used to break ownership cycles
B.RAII — a technique that ties resource acquisition to object construction and release to destruction, guaranteeing cleanup when scope exits even on exceptions
C.RAII — a move-only smart pointer expressing exclusive ownership that automatically deletes its managed object and cannot be copied
D.RAII — allocates an object on the free store and runs its constructor, returning a pointer that must later be released to avoid a leak
Answer + AI explanation with Pro
7. What is std::unique_ptr?
Mid
A.a move-only smart pointer expressing exclusive ownership that automatically deletes its managed object and cannot be copied
B.allocates an object on the free store and runs its constructor, returning a pointer that must later be released to avoid a leak
C.a reference-counted smart pointer that deletes its managed object only when the last owner sharing the count is destroyed
D.a technique that ties resource acquisition to object construction and release to destruction, guaranteeing cleanup when scope exits even on exceptions
Answer + AI explanation with Pro
8. Which term means: "a move-only smart pointer expressing exclusive ownership that automatically deletes its managed object and cannot be copied"?
Mid
A.std::unique_ptr
B.std::shared_ptr
C.new expression
D.std::weak_ptr
Answer + AI explanation with Pro
9. Which statement is correct?
Mid
A.std::unique_ptr — a non-owning observer of a shared resource that does not affect the reference count and is used to break ownership cycles
B.std::unique_ptr — a reference-counted smart pointer that deletes its managed object only when the last owner sharing the count is destroyed
C.std::unique_ptr — allocates an object on the free store and runs its constructor, returning a pointer that must later be released to avoid a leak
D.std::unique_ptr — a move-only smart pointer expressing exclusive ownership that automatically deletes its managed object and cannot be copied
Answer + AI explanation with Pro
10. What is std::shared_ptr?
Mid
A.a non-owning observer of a shared resource that does not affect the reference count and is used to break ownership cycles
B.a technique that ties resource acquisition to object construction and release to destruction, guaranteeing cleanup when scope exits even on exceptions
C.a reference-counted smart pointer that deletes its managed object only when the last owner sharing the count is destroyed
D.allocates an object on the free store and runs its constructor, returning a pointer that must later be released to avoid a leak
Answer + AI explanation with Pro
11. Which term means: "a reference-counted smart pointer that deletes its managed object only when the last owner sharing the count is destroyed"?
Mid
A.new expression
B.std::shared_ptr
C.RAII
D.std::unique_ptr
Answer + AI explanation with Pro
12. Which statement is correct?
Mid
A.std::shared_ptr — a non-owning observer of a shared resource that does not affect the reference count and is used to break ownership cycles
B.std::shared_ptr — a reference-counted smart pointer that deletes its managed object only when the last owner sharing the count is destroyed
C.std::shared_ptr — a technique that ties resource acquisition to object construction and release to destruction, guaranteeing cleanup when scope exits even on exceptions
D.std::shared_ptr — a move-only smart pointer expressing exclusive ownership that automatically deletes its managed object and cannot be copied
Answer + AI explanation with Pro
13. What is std::weak_ptr?
Senior
A.a move-only smart pointer expressing exclusive ownership that automatically deletes its managed object and cannot be copied
B.a technique that ties resource acquisition to object construction and release to destruction, guaranteeing cleanup when scope exits even on exceptions
C.allocates an object on the free store and runs its constructor, returning a pointer that must later be released to avoid a leak
D.a non-owning observer of a shared resource that does not affect the reference count and is used to break ownership cycles
Answer + AI explanation with Pro
14. Which term means: "a non-owning observer of a shared resource that does not affect the reference count and is used to break ownership cycles"?
Senior
A.RAII
B.new expression
C.std::weak_ptr
D.std::shared_ptr
Answer + AI explanation with Pro
15. Which statement is correct?
Senior
A.std::weak_ptr — a move-only smart pointer expressing exclusive ownership that automatically deletes its managed object and cannot be copied
B.std::weak_ptr — allocates an object on the free store and runs its constructor, returning a pointer that must later be released to avoid a leak
C.std::weak_ptr — a technique that ties resource acquisition to object construction and release to destruction, guaranteeing cleanup when scope exits even on exceptions
D.std::weak_ptr — a non-owning observer of a shared resource that does not affect the reference count and is used to break ownership cycles
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 Memory and RAII question come with Pro.