Test Series - cpp

Test Number 53/102

Q: What will happen when a programs throws any other type of exception other than specified?
A. terminate
B. arise an error
C. run
D. throw
Solution: Because there is no way defined to catch that exception and as we know if an exception is not caught then error arises.
Q: What do you mean by “No exception specification”?
A. It throws nothing
B. It can throw anything
C. It can catch anything
D. It can try anything
Solution: No exception specification that it can throw anything.
Q: Which operations don’t throw anything?
A. Operations which are reversible
B. Operations which are irreversible
C. Operations which are static
D. Operations which are dynamic
Solution: Operations which are irreversible cannot throw anything.
Q: What happens if try catch block is not used?
A. arise an error
B. program will run
C. execute continuously
D. wrong output
Solution: If try catch block is not used the exception thrown by the program will be uncaught hence will result into error(s).
Q: Which handler is used to handle all types of exception?
A. catch handler
B. catch-all handler
C. catch-none handler
D. try-catch handler
Solution: To catch all types of exceptions, we use the catch-all handler.
Q: Which operator is used as catch-all handler?
A. ellipses operator
B. ternary operator
C. string operator
D. unary operator
Solution: The ellipses operator can be represented as (…).
Q: What function will be called when we have an uncaught exception?
A. catch
B. throw
C. terminate
D. try
Solution: If we have an uncaught exception means, the compiler will throw the control of the program to terminate function.
Q: What will not be called when the terminate() is raised in the constructor?
A. main()
B. class
C. destructor
D. constructor
Solution: To free the memory occupied by that object during initializing and destroy that object.
Q: What will happen when we move to try block far away from catch block?
A. Reduces the amount of code in cache
B. Increases the amount of code in cache
C. Don’t alter anything
D. Increases the amount of code
Solution: compilers may try to move the catch-code far away from the try-code, which reduces the amount of code to keep in cache normally, thus enhancing performance.
Q: What will happen if an exception that is thrown may cause a whole load of objects to go out of scope?
A. Terminate the program
B. Produce a runtime error
C. It will be added to the overhead
D. Compilation error
Solution: It will be added to the overhead if an exception that is thrown may cause a whole load of objects to go out of scope.

You Have Score    /10