C# Questions & Answers – Byte Stream

«
»

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

Answer: c
Explanation: None.
advertisement

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

Answer: d
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

Answer: a
Explanation: InputStream & OutputStream are designed for byte stream. Reader and writer are designed for character stream.
advertisement
advertisement

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

Answer: c
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

Answer: d
Explanation: A byte stream that uses unmanaged memory for storage.
advertisement

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

Answer: a
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

Answer: a
Explanation: Creates a new output file. The file must not already be existing.
advertisement

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

Answer: b
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

Answer: b
Explanation: None.
advertisement

10. Which of these is a method used for reading bytes from the file?
a) clear()
b) ReadByte()
c) put()
d) write()
View Answer

Answer: b
Explanation: FileStream defines two methods that reads bytes from a file: ReadByte() and Read().

Sanfoundry Global Education & Learning Series – C# Programming Language.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

advertisement
advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter