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:
- D) i, ii and iv only
- B) FileInfo
- C) FileStream
- C) i-True, ii-True
- A) Read()
- A) Flush()
- D) i, ii and iv only
- C) i, iii and iv only
- B) AppendText()
- C) GetCreationTimeUTC()
- D) i, ii and iv only
- B) WriteAllLines()
- C) i, iii and iv only
- C) i-False, ii-True, iii-True
- B) ii, iii and iv only
- A) i and iii only
- A) i-True, ii-False
- C) OpenText()
- A) i-True, ii-False
- D) ReadAllLines()