Question 1
How can you create a temporary file that is automatically deleted when closed?
Using the tmpfile() function
Using the tempfile() function
Using the tmpstream class
Using the tempstream class
Question 2
Which of the following is the correct syntax to handle exceptions in C++?
try { ... } catch { ... }
try { ... } catch(Exception e) { ... }
try { ... } throw(Exception e) { ... }
catch { ... } try { ... }
Question 3
What happens if an exception is thrown but no catch block matches it?
Program skips the exception
Program terminates using std::terminate()
It is silently ignored
Control goes back to the main function
Question 4
Which standard exception class is thrown when memory allocation with new fails?
std::runtime_error
std::bad_alloc
std::overflow_error
std::invalid_argument
Question 5
What is the output of the following code?
#include <iostream>
using namespace std;
int main() {
try {
throw 10;
}
catch (char e) {
cout << "Char Exception";
}
catch (...) {
cout << "Default Handler";
}
}
Char Exception
Default Handler
Compilation Error
No Output
Question 6
Which keyword is used to rethrow the currently handled exception inside a catch block?
retry
throw
catch
throw e
There are 6 questions to complete.