Solution: The garbage collection attempts to reclaim memory occupied by objects that are no longer in use by the program.
Q: What are the operators available in C++ for dynamic allocation and de-allocation of memories?
A. new
B. delete
C. compare
D. both new & delete
Solution: new and delete operators are mainly used to allocate and deallocate during runtime.
Q: Which is used to solve the memory management problem in c++?
A. smart pointers
B. arrays
C. stack
D. queue
Solution: In C++, smart pointers are used to manage memory issues like deallocate memory after use, checking bounds, etc.
Q: Which is used to handle the exceptions in c++?
A. catch handler
B. handler
C. exception handler
D. throw
Solution: Exception handler is used to handle the exceptions in c++.
Q: Which type of program is recommended to include in try block?
A. static memory allocation
B. dynamic memory allocation
C. const reference
D. pointer
Solution: While during dynamic memory allocation, Your system may not have sufficient resources to handle it, So it is better to use it inside the try block.
Q: Which statement is used to catch all types of exceptions?
A. catch()
B. catch(Test t)
C. catch(…)
D. catch(Test)
Solution: This catch statement will catch all types of exceptions that arises in the program.
Q: How to handle error in the destructor?
A. throwing
B. terminate
C. both throwing & terminate
D. try
Solution: It will not throw an exception from the destructor but it will the process by using terminate() function.
Q: What kind of exceptions are available in c++?
A. handled
B. unhandled
C. static
D. dynamic
Solution: unhandled kind of exceptions are available in c++.
Q: What is meant by exception specification?
A. A function is limited to throwing only a specified list of exceptions
B. A catch can catch all types of exceptions
C. A function can throw any type of exceptions
D. A try can catch all types of exceptions
Solution: C++ provides a mechanism to ensure that a given function is limited to throwing only a specified list of exceptions. It is called an exception specification.
Q: Identify the correct statement about throw(type).
A. A function can throw any type of exceptions
B. A function can throw an exception of certain type only
C. A function can’t throw any type of exception
D. A function can catch all types of exceptions
Solution: A function can throw an exception of certain type only.