Skip to main content

File Handling In C Plus Plus — Part 1 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on File Handling In C Plus Plus — Part 1 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.

Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40

Verified Practice Questions

Interactive test mode with detailed academic worked solutions

Live Progress | 0/40 answered
✓ 0 correct ✗ 0 wrong 0% score
Question 1 of 40
★ FPSC ★ PPSC

What is the function used to create a new file in C++?

Question 2 of 40
★ FPSC ★ PPSC

Which header file is required for file handling in C++?

Question 3 of 40
★ FPSC ★ PPSC

What is the function used to open a file in C++?

Question 4 of 40
★ FPSC ★ PPSC

How do you close a file in C++?

Question 5 of 40
★ FPSC ★ PPSC

Which mode is used to open a file for writing in C++?

Question 6 of 40
★ FPSC ★ PPSC

What is the correct syntax for writing data to a file in C++?

Question 7 of 40
★ FPSC ★ PPSC

How do you check if a file has been successfully opened in C++?

Question 8 of 40
★ FPSC ★ PPSC

Which of the following is used to read data from a file in C++?

Question 9 of 40
★ FPSC ★ PPSC

What does the seekg() function do in C++ file handling?

Question 10 of 40
★ FPSC ★ PPSC

Which function is used to delete a file in C++?

Question 11 of 40
★ FPSC ★ PPSC

Which file mode is used to open a file for reading and writing in C++?

Question 12 of 40
★ FPSC ★ PPSC

How do you check if the end of a file has been reached in C++?

Question 13 of 40
★ FPSC ★ PPSC

Which function is used to get the current position of the file pointer in C++?

Question 14 of 40
★ FPSC ★ PPSC

What is the purpose of the ios::app flag in C++ file handling?

Question 15 of 40
★ FPSC ★ PPSC

Which function is used to check if a file exists in C++?

Question 16 of 40
★ FPSC ★ PPSC

How do you create a new file in C++?

Question 17 of 40
★ FPSC ★ PPSC

Which file mode is used to open a file for reading only in C++?

Question 18 of 40
★ FPSC ★ PPSC

How do you check if a file exists before opening it in C++?

Question 19 of 40
★ FPSC ★ PPSC

Which of the following is not a file stream class in C++?

Question 20 of 40
★ FPSC ★ PPSC

What is the function used to write data to a file in C++?

Question 21 of 40
★ FPSC ★ PPSC

Which function is used to set the file position in C++ file handling?

Question 22 of 40
★ FPSC ★ PPSC

What is the purpose of the ios::ate flag in C++ file handling?

Question 23 of 40
★ FPSC ★ PPSC

In C++, how do you check if a file has reached the end while reading?

Question 24 of 40
★ FPSC ★ PPSC

Which function is used to rewind the file pointer to the beginning of the file in C++?

Question 25 of 40
★ FPSC ★ PPSC

What is the function used to read a single character from a file in C++?

Question 26 of 40
★ FPSC ★ PPSC

Which of the following is not a valid file mode in C++?

Question 27 of 40
★ FPSC ★ PPSC

How do you delete a file in C++?

Question 28 of 40
★ FPSC ★ PPSC

Which function is used to return the current file pointer position in C++?

Question 29 of 40
★ FPSC ★ PPSC

Which function is used to check if a file is open or not in C++?

Question 30 of 40
★ FPSC ★ PPSC

What happens if you try to open a file that does not exist in C++ without specifying any flags?

Question 31 of 40
★ FPSC ★ PPSC

Which file mode in C++ opens a file for reading and writing, and truncates it to zero length if it exists?

Question 32 of 40
★ FPSC ★ PPSC

What is the difference between fstream and ofstream in C++?

Question 33 of 40
★ FPSC ★ PPSC

How do you check if a file operation in C++ has encountered an error?

Question 34 of 40
★ FPSC ★ PPSC

What is the purpose of the ios::binary flag in C++ file handling?

Question 35 of 40
★ FPSC ★ PPSC

Which of the following is used to close a file in C++?

Question 36 of 40
★ FPSC ★ PPSC

In C++, how do you check if a file operation has reached the end of the file?

Question 37 of 40
★ FPSC ★ PPSC

Which function is used to set the position of the file pointer in C++ file handling?

Question 38 of 40
★ FPSC ★ PPSC

How do you check if a file exists in C++ before opening it?

Question 39 of 40
★ FPSC ★ PPSC

What is the purpose of the ios::trunc flag in C++ file handling?

Question 40 of 40
★ FPSC ★ PPSC

Which file mode in C++ opens a file for reading and writing without truncating it if it exists?

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 Examiner's Advisory for Programming & Software Development

In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →