Programming MCQs

20 Most Important MCQ Questions on I/O Classes in C#

Pinterest LinkedIn Tumblr
Here are the collections of 20 most important MCQ questions on I/O classes includes the multiple-choice questions on the classes offered by System.IO namespace in .NET. It includes objective-type questions on different I/O classes such as FileStream class, StreamWriter class, StreamReader class, BinaryReader class, BinaryWriter class, File class, and FileInfo class along with the methods used by these classes.

Read Also: Top 20 MCQ Questions on C# Collection Classes

1. … are the most commonly used classes on the System.IO namespace.
i) BinaryReader
ii) File
iii) FileFormat
iv) DirectoryInfo
A) i, ii and iii only
B) ii, iii and iv only
C) i, iii and iv only
D) i, ii and iv only

2. The … class in the System.IO namespace is used for performing operations on the file.
A) File
B) FileInfo
C) FileStream
D) FileWriter

3. The … class in the System.IO namespace is used to read from and write to any location in a file.
A) File
B) FileInfo
C) FileStream
D) FileWriter

4. State whether the following statements about the FileStream Class are True or False.
i) This class can open a file either synchronously and asynchronously.
ii) You can create, open and share files with the help of the constructors of the FileStream class.
A) i-True, ii-False
B) i-False, ii-True
C) i-True, ii-True
D) i-False, ii-False

5. The … method in the StreamReader class reads the next character from the input stream and advances the character position by one character.
A) Read()
B) ReadNext()
C) ReadLine()
D) ReadToEnd()

6. The … method in the StreamWriter class clears all buffers for the current writer and causes any buffered data to be written to the underlying stream.
A) Flush()
B) Clear()
C) FlushBuffer()
D) ClearBuffer()

7. Which of the following is/are the methods of BinaryReader class offered by the System.IO namespace.
i) Dispose()
ii) Finalize()
iii) Flush()
iv) ToString()
A) i, ii and iii only
B) ii, iii and iv only
C) i, iii and iv only
D) i, ii and iv only

8. Which of the following is/are the methods of StreamReader class offered by the System.IO namespace.
i) Dispose()
ii) Finish()
iii) ReadToEnd()
iv) Close()
A) i, ii and iii only
B) ii, iii and iv only
C) i, iii and iv only
D) i, ii and iv only

9. … is the method of File class that creates a StreamWriter that appends UTF-8 encoded text to an existing file, or to a new file if the specified file does not exist.
A) AppendAllText()
B) AppendText()
C) AppendUTFText()
D) AppendAllLines()

10. … is the method of File class that returns the creation date and time, in coordinated universal time of the specified file or directly.
A) GetTime()
B) GetCreationTime()
C) GetCreationTimeUTC()
D) GetCreationDateTime()

11. … are the methods of File class offered by System.IO namespace.
i) Open()
ii) Move()
iii) Stop()
iv) Create()
A) i, ii and iii only
B) ii, iii and iv only
C) i, iii and iv only
D) i, ii and iv only

12. The method … in the File class creates a new file, writes a collection of strings to the file, and then closes the file.
A) WriteLines()
B) WriteAllLines()
C) WriteAllText()
D) WriteAllBytes()

13. Which of the following are the methods of FileInfo class offered by the System.IO namespace.
i) Encrypt()
ii) Copy(string)
iii) Delete()
iv) OpenRead()
A) i, ii and iii only
B) ii, iii and iv only
C) i, iii and iv only
D) i, ii and iv only

14. State whether the following statements about the I/O class are True or False.
i) The Directory class is used for performing operations on directories.
ii) The File class helps in manipulating files.
iii) The DriveInfo class provides information for the drives.
A) i-True, ii-False, iii-True
B) i-True, ii-True, iii-True
C) i-False, ii-True, iii-True
D) i-False, ii-True, iii-False

15. Which of the following is/are the methods of the Filestream class.
i) StartRead()
ii) Close()
iii) EndRead()
iv) Seek()
A) i, ii and iii only
B) ii, iii and iv only
C) i, iii and iv only
D) i, ii and iv only

16. … are the methods of BinaryWriter class offered by System.IO namespace.
i) Flush()
ii) End()
iii) GetType()
iv) String()
A) i and iii only
B) ii and iv only
C) ii, iii and iv only
D) i, ii and iii only

17. State whether the following statements about the FileInfo class are True or False.
i) It helps to create Filestream objects.
ii) You can inherit the FileInfo class.
A) i-True, ii-False
B) i-True, ii-True
C) i-False, ii-True
D) i-False, ii-False

18. The … method in the FileInfo class creates a StreamReader with UTF-8 encoding that reads from existing text file.
A) OpenRead()
B) Open(FileMode)
C) OpenText()
D) OpenUTFText()

19. State whether the following statements about the File class are True or False.
i) Using the File class, you can set the date and time of creating, writing, and accessing files.
ii) The create() method creates or opens a file for writing UTF-8 encoded text.
A) i-True, ii-False
B) i-True, ii-True
C) i-False, ii-True
D) i-False, ii-False

20. The … method in the File class opens a text file, reads all lines of the file, and then closes the file.
A) ReadAllText()
B) ReadAllBytes()
C) ReadAllFiles()
D) ReadAllLines()

Answers:

  1. D) i, ii and iv only
  2. B) FileInfo
  3. C) FileStream
  4. C) i-True, ii-True
  5. A) Read()
  6. A) Flush()
  7. D) i, ii and iv only
  8. C) i, iii and iv only
  9. B) AppendText()
  10. C) GetCreationTimeUTC()
  11. D) i, ii and iv only
  12. B) WriteAllLines()
  13. C) i, iii and iv only
  14. C) i-False, ii-True, iii-True
  15. B) ii, iii and iv only
  16. A) i and iii only
  17. A) i-True, ii-False
  18. C) OpenText()
  19. A) i-True, ii-False
  20. D) ReadAllLines()
Please follow and like us:
RSS
Follow by Email
X (Twitter)
Visit Us
Follow Me
YouTube
YouTube
LinkedIn
linkedIn | 20 Most Important MCQ Questions on I/O Classes in C#
Share

Author

Shuseel Baral is a web programmer and the founder of InfoTechSite has over 8 years of experience in software development, internet, SEO, blogging and marketing digital products and services is passionate about exceeding your expectations.

Comments are closed.

RSS
Follow by Email
X (Twitter)
Visit Us
Follow Me
YouTube
YouTube
LinkedIn
Share