--:--









Quiz for File modes and error handling

Course: C++ Language | Subject: Unit 12 | Topic: File Handling



Logo

Q1: Which file mode is used to open a file for reading only?

Logo

Q2: Which file mode opens a file for writing only?

Logo

Q3: Which mode appends data at the end of the file?

Logo

Q4: What does ios::trunc mode do?

Logo

Q5: Which mode combination opens file for both input and output?

Logo

Q6: What does the fail() function indicate?

Logo

Q7: What is checked by the eof() function?

Logo

Q8: Which function clears error flags?

Logo

Q9: What does the bad() function indicate?

Logo

Q10: How can you check if a file stream is good for I/O?

Logo

Q11: What happens if you open a file in ios::out mode and it does not exist?

Logo

Q12: Which mode allows reading and appending?

Logo

Q13: Which method closes an open file?

Logo

Q14: Which of the following is NOT an ios::openmode?

Logo

Q15: How do you prevent truncation while opening a file for output?

Logo

Q16: Which flag is needed to open a file in binary mode?

Logo

Q17: If fail() returns true, what is a common cause?

Logo

Q18: Which function returns true if the file stream has no errors?

Logo

Q19: What is the default mode for ifstream?

Logo

Q20: What does ios::ate mode do when opening a file?

Are you ready to start test? Set your time limit