File Handling And Input Output In C Sharp — Part 2 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on File Handling And Input Output In C Sharp — Part 2 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
🎉 Set complete! All 40 questions answered.
Question 1 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C# code snippet? static void Main(string[] args) { StringBuilder sb = new StringBuilder("hello world"); sb.Insert(6, "good"); Console.WriteLine(sb); Console.ReadLine(); }
Correct Answer: Option C — hello goodworld
Detailed Academic Explanation:
hello goodworld is the correct answer to “What will be the output of the following C# code snippet? static void Main(string[] args) { StringBuilder sb = new StringBuilder("hello world"); sb.Insert(6, "good"); Console.WriteLine(sb); Console.ReadLine(); }”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Choose the output returned when read() reads the character from the console?
Correct Answer: Option C — Integer
Detailed Academic Explanation:
Integer is the correct answer to “Choose the output returned when read() reads the character from the console”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the given stream methods provide access to the output console by default in C#.NET?
Correct Answer: Option B — Console.Out
Detailed Academic Explanation:
Console.Out is the correct answer to “Which of the given stream methods provide access to the output console by default in C#.NET”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output for following input from the console as a character? static void Main(string[] args) { Console.WriteLine("what is your name?"); char s; s = Convert.ToChar(Console.ReadLine()); Console.WriteLine("how are you: "+s); Console.Read(); }
Correct Answer: Option D — Run time error
Detailed Academic Explanation:
Run time error is the correct answer to “What will be the output for following input from the console as a character? static void Main(string[] args) { Console.WriteLine("what is your name?"); char s; s = Convert.ToChar(Console.ReadLine()); Console.WriteLine("how are you: "+s); Console.Read(); }”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Choose the object of TextReader class.
Correct Answer: Option A — Console.In
Detailed Academic Explanation:
Console.In is the correct answer to “Choose the object of TextReader class.”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is the correct statement about inspecting an attribute in C#.NET?
Correct Answer: Option A — An attribute can be inspected at link time
Detailed Academic Explanation:
An attribute can be inspected at link time is the correct answer to “Which of the following is the correct statement about inspecting an attribute in C#.NET”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Choose the output returned when an error condition is generated while read() reads from the console.
Correct Answer: Option C — -1
Detailed Academic Explanation:
-1 is the correct answer to “Choose the output returned when an error condition is generated while read() reads from the console.”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which among the following methods are used to write characters to a string?
Correct Answer: Option C — StringWriter
Detailed Academic Explanation:
StringWriter is the correct answer to “Which among the following methods are used to write characters to a string”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The correct method to pass a parameter to an attribute is?
Correct Answer: Option A — By name
Detailed Academic Explanation:
By name is the correct answer to “The correct method to pass a parameter to an attribute is”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which among the following attempts to read up to count bytes into buffer starting at buffer[offset], returning the number of bytes successfully read?
Correct Answer: Option B — int Read(byte[] buffer, int offset, int count)
Detailed Academic Explanation:
int Read(byte[] buffer, int offset, int count) is the correct answer to “Which among the following attempts to read up to count bytes into buffer starting at buffer[offset], returning the number of bytes successfully read”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which method of the character stream class returns the numbers of characters successfully read starting at index?
Correct Answer: Option C — int ReadBlock(char[ ] buffer, int index, int count)
Detailed Academic Explanation:
int ReadBlock(char[ ] buffer, int index, int count) is the correct answer to “Which method of the character stream class returns the numbers of characters successfully read starting at index”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which method among the following returns the integer if no character is available?
Correct Answer: Option A — int peek()
Detailed Academic Explanation:
int peek() is the correct answer to “Which method among the following returns the integer if no character is available”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Choose the correct statement about the WriteLine()?
Correct Answer: Option D — All of the mentioned
Detailed Academic Explanation:
All of the mentioned is the correct answer to “Choose the correct statement about the WriteLine()”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Select the method which returns the number of bytes from the array buffer:
Correct Answer: Option B — int Write(byte[] buffer, int offset, int count)
Detailed Academic Explanation:
int Write(byte[] buffer, int offset, int count) is the correct answer to “Select the method which returns the number of bytes from the array buffer:”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these classes is used to create an object whose character sequence is mutable?
Correct Answer: Option B — StringBuilder()
Detailed Academic Explanation:
StringBuilder() is the correct answer to “Which of these classes is used to create an object whose character sequence is mutable”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C# code? static void Main(string[] args) { Console.WriteLine("This is a Console Application:"); Console.Write("Please enter your lucky number:"); string val1 = Console.ReadLine(); int val2 = System.Convert.ToInt32(val1, 10); val2 = val2 * val2; Console.WriteLine("square of number is:" +val2); Console.Read(); }
Correct Answer: Option C — Runs successfully, ask for input and hence displays the result
Detailed Academic Explanation:
Runs successfully, ask for input and hence displays the result is the correct answer to “What will be the output of the following C# code? static void Main(string[] args) { Console.WriteLine("This is a Console Application:"); Console.Write("Please enter your lucky number:"); string val1 = Console.ReadLine(); int val2 = System.Convert.ToInt32(val1, 10); val2 = val2 * val2; Console.WriteLine("square of number is:" +val2); Console.Read(); }”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these classes are used by Byte streams for input and output operation?
Correct Answer: Option B — InputOutputStream
Detailed Academic Explanation:
InputOutputStream is the correct answer to “Which of these classes are used by Byte streams for input and output operation”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which among the following is used for storage of unmanaged memory aspects?
Correct Answer: Option D — UnmanagedMemoryStream
Detailed Academic Explanation:
UnmanagedMemoryStream is the correct answer to “Which among the following is used for storage of unmanaged memory aspects”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Select the namespace on which the stream classes are defined?
Correct Answer: Option A — System.IO
Detailed Academic Explanation:
System.IO is the correct answer to “Select the namespace on which the stream classes are defined”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Select the method used to write single byte to a file?
Correct Answer: Option C — WriteByte()
Detailed Academic Explanation:
WriteByte() is the correct answer to “Select the method used to write single byte to a file”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Choose the filemode method which is used to create a new output file with the condition that the file with same name if exists will destroy the old file:
Correct Answer: Option B — FileMode.Create
Detailed Academic Explanation:
FileMode.Create is the correct answer to “Choose the filemode method which is used to create a new output file with the condition that the file with same name if exists will destroy the old file:”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which method of character stream class returns the numbers of characters successfully read starting at count?
Correct Answer: Option B — int Read(char[] buffer, int index, int count)
Detailed Academic Explanation:
int Read(char[] buffer, int index, int count) is the correct answer to “Which method of character stream class returns the numbers of characters successfully read starting at count”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
To apply an attribute to an Assembly, the correct way of implementation is?
Correct Answer: Option B — [assembly: AssemblyDescription("Csharp")]
Detailed Academic Explanation:
[assembly: AssemblyDescription("Csharp")] is the correct answer to “To apply an attribute to an Assembly, the correct way of implementation is”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Choose the filemode method which is used to create a new output file with the condition that the file with same name must not exist.
Correct Answer: Option A — FileMode.CreateNew
Detailed Academic Explanation:
FileMode.CreateNew is the correct answer to “Choose the filemode method which is used to create a new output file with the condition that the file with same name must not exist.”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which among the following classes are used to perform the character based file operations?
Correct Answer: Option A — StreamReader
Detailed Academic Explanation:
StreamReader is the correct answer to “Which among the following classes are used to perform the character based file operations”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Name the method which returns integer as -1 when the end of file is encountered.
Correct Answer: Option B — int ReadByte()
Detailed Academic Explanation:
int ReadByte() is the correct answer to “Name the method which returns integer as -1 when the end of file is encountered.”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these is a method used to clear all the data present in output buffers?
Correct Answer: Option B — flush()
Detailed Academic Explanation:
flush() is the correct answer to “Which of these is a method used to clear all the data present in output buffers”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Attributes could be applied to . . . . . . . .
Correct Answer: Option D — All of the mentioned
Detailed Academic Explanation:
All of the mentioned is the correct answer to “Attributes could be applied to . . . . . . . .”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these method/methods are used to read block or array of bytes from the file?
Correct Answer: Option A — Read()
Detailed Academic Explanation:
Read() is the correct answer to “Which of these method/methods are used to read block or array of bytes from the file”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the classes provide the operation of reading from and writing to the console in C#.NET?
Correct Answer: Option D — System.Console
Detailed Academic Explanation:
System.Console is the correct answer to “Which of the classes provide the operation of reading from and writing to the console in C#.NET”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Name the exception thrown by read() on failure.
Correct Answer: Option D — I/O Exception
Detailed Academic Explanation:
I/O Exception is the correct answer to “Name the exception thrown by read() on failure.”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Name the method/methods used to read byte streams from the file?
Correct Answer: Option A — ReadByte()
Detailed Academic Explanation:
ReadByte() is the correct answer to “Name the method/methods used to read byte streams from the file”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The [Serializable()] attributes gets inspected at . . . . . . . .
Correct Answer: Option B — run time
Detailed Academic Explanation:
run time is the correct answer to “The [Serializable()] attributes gets inspected at . . . . . . . .”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Select the method which writes the contents of the stream to the physical device.
Correct Answer: Option C — void Flush()
Detailed Academic Explanation:
void Flush() is the correct answer to “Select the method which writes the contents of the stream to the physical device.”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output returned by Console if ReadLine() stores I/O error?
Correct Answer: Option D — I/O EXCEPTION ERROR
Detailed Academic Explanation:
I/O EXCEPTION ERROR is the correct answer to “What is the output returned by Console if ReadLine() stores I/O error”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which among the following cannot be a target for a custom attribute?
Correct Answer: Option D — Namespace
Detailed Academic Explanation:
Namespace is the correct answer to “Which among the following cannot be a target for a custom attribute”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Choose the class on which all stream classes are defined?
Correct Answer: Option A — System.IO.stream
Detailed Academic Explanation:
System.IO.stream is the correct answer to “Choose the class on which all stream classes are defined”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these classes is used for input and output operation when working with bytes?
Correct Answer: Option A — InputStream
Detailed Academic Explanation:
InputStream is the correct answer to “Which of these classes is used for input and output operation when working with bytes”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which method in Console enables to read individual inputs directly from the keyboard in a non line buffered manner?
Correct Answer: Option B — ReadKey()
Detailed Academic Explanation:
ReadKey() is the correct answer to “Which method in Console enables to read individual inputs directly from the keyboard in a non line buffered manner”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Select the objects of the class TextWriter which is/are not used to perform the write operations to the console?
Correct Answer: Option C — WriteError()
Detailed Academic Explanation:
WriteError() is the correct answer to “Select the objects of the class TextWriter which is/are not used to perform the write operations to the console”. This question is standard in competitive examination syllabi for File Handling And Input Output In C Sharp.
💡Key Conceptual Anchor:File Handling And Input Output In C Sharp
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡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.