VOOZH about

URL: https://www.geeksforgeeks.org/quizzes/quiz-on-cpp-file-handling/

⇱ Quiz about Quiz on C++ File Handling


Last Updated :
Discuss
Comments

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 used to open a file for reading in C++?

  • ofstream file("data.txt");

  • ifstream file("data.txt");

  • fstream file("data.txt", ios::out);

  • file.open("data.txt", ios::write);

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?


  • 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.

Take a part in the ongoing discussion