This section of our 1000+ C# MCQs focuses in detail on byte stream in C# Programming Language.
1. Which of these classes is used to read and write bytes in a file?
a) FileReader
b) FileWriter
c) FileInputStream
d) InputStreamReader
View Answer
Explanation: None.
2. Which of these data types is returned by every method of OutputStream?
a) int
b) float
c) byte
d) none of the mentioned
View Answer
Explanation: Every method of OutputStream returns void and throws an IOExeption in case of errors.
3. Which of these classes is used for input and output operation when working with bytes?
a) InputStream
b) Reader
c) Writer
d) All of the mentioned
View Answer
Explanation: InputStream & OutputStream are designed for byte stream. Reader and writer are designed for character stream.
4. Which among the following is used for storage of memory aspects?
a) BufferedStream
b) FileStream
c) MemoryStream
d) None of the mentioned
View Answer
Explanation: A byte stream that uses memory for storage.
5. Which among the following is used for storage of unmanaged memory aspects?
a) BufferedStream
b) FileStream
c) MemoryStream
d) UnmanagedMemoryStream
View Answer
Explanation: A byte stream that uses unmanaged memory for storage.
6. Which property among the following represents the current position of the stream?
a) long Length
b) long Position
c) int Length
d) all of the mentioned
View Answer
Explanation: This property contains the length of the stream. This property is read-only.
7. 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.
a) FileMode.CreateNew
b) FileMode.Create
c) FileMode.OpenOrCreate
d) FileMode.Truncate
View Answer
Explanation: Creates a new output file. The file must not already be existing.
8. 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:
a) FileMode.CreateNew
b) FileMode.Create
c) FileMode.OpenOrCreate
d) FileMode.Truncate
View Answer
Explanation: Creates a new output file. Any pre-existing file with the same name will be destroyed.
9. Which of these is a method used to clear all the data present in output buffers?
a) clear()
b) flush()
c) fflush()
d) close()
View Answer
Explanation: None.
10. Which of these is a method used for reading bytes from the file?
a) clear()
b) ReadByte()
c) put()
d) write()
View Answer
Explanation: FileStream defines two methods that reads bytes from a file: ReadByte() and Read().
Sanfoundry Global Education & Learning Series – C# Programming Language.
To practice all areas of C# language, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Practice Computer Science MCQs
- Check Computer Science Books
- Check C# Books
- Apply for C# Internship
- Check MCA Books