Object Oriented Programming using C++ Questions and Answers – IO Class

«
»

This set of Object Oriented Programming (OOPs) using C++ Multiple Choice Questions & Answers (MCQs) focuses on “IO Class”.

1. What is the use of IO class?
a) To handle all the input operations
b) To handle all the output operations
c) To handle all the input and output operations
d) To handle all the input and output to the standard input
View Answer

Answer: c
Explanation: The IO class provides functions that can be used to handle input and output operations. All the inputs from standard input and standard output, and also from the files can be handled. This gives the flexibility to make the programs more user friendly.
advertisement

2. IO class provides input and output through ______________________
a) Data streams
b) Serialization
c) File system
d) Data streams, serialization and file system
View Answer

Answer: d
Explanation: The IO classes are made such that those can support the input and output from any type of source or destination. The input can be taken from system file and standard input and also some special devices if conned. Same is case to show the output.

3. Which among the following class contains the methods to access character based console device?
a) Console
b) File
c) Device
d) Pipe
View Answer

Answer: a
Explanation: The Console class contains the methods to access the character based devices. The devices which can stream the data as character set. All those devices can be made use of by using the methods of class Console.
advertisement
advertisement

4. File class is ____________________________
a) An abstract of file representation only
b) An abstract of path names only
c) An abstract which can be used to represent path names or file
d) An abstract which can represent a file in any format
View Answer

Answer: c
Explanation: The File class is made to operate with the files. The file can be of any type. All the input and output operations that have to be performed on a file can be done using File class object.

5. What is a FileDescriptor?
a) A handle for machine specific structure of an open file
b) A handle for program specific structure of an open file
c) A handle for compiler specific structure of an open file
d) A handle for representing device files structure
View Answer

Answer: a
Explanation: The machine specific structure of an open file have to be handled in some special ways. FileDescriptor class can handle those files. The FileDescriptor can also handle open socket, another source, sink of bytes.
advertisement

6. FileInputStream _________________________
a) Gets the input stream from any device file
b) Gets the input stream from any open socket
c) Gets the input stream from any cache
d) Gets the input stream from any open file only
View Answer

Answer: d
Explanation: The most specific answer is that the FileInputStream can only be used for the opened files. The class can work only for the file type. No socket or another source are allowed to be accessed.

7. What does FilePermission class do?
a) This class is used to give permission rights to a file
b) This class is used to restrict the use of permissions
c) This class is used to represent device access permissions
d) This class is used to represent file access permissions
View Answer

Answer: d
Explanation: The FilePermission can’t get access to the device access permissions. The Permission is given to a file when it is created or otherwise when a privileged user changes it. Then these permission rights can be accessed using the FilePermission class.
advertisement

8. Which class among the following makes incorrect assumptions?
a) LineNumberInputStream
b) LineNumberReader
c) LineReader
d) LineBuffer
View Answer

Answer: a
Explanation: The LineNumberInputStream class makes false assumptions. The false assumption is that it assumes, all the byte data is a character. Which is actually not the case, instead the character have one byte memory space.

9. Reader class is _________________
a) Used to read from files
b) Abstract class to read character streams
c) Abstract class to input character streams
d) Used to take input from standard input stream
View Answer

Answer: b
Explanation: The Reader class is an abstract class that can be used to read characters stream. It can’t be used for any kind of input. It can just read the existing data.
advertisement

10. Which class can handle IO class interrupt?
a) ExceptionIO
b) InteruptedIO
c) InteruptedIOException
d) IOInteruptException
View Answer

Answer: c
Explanation: The only class which handles the IO class interrupts is InteruptedIOException class. This class is specially provided to handle any case that involves the execution interrupt.

11. StringReader handles _____________________
a) Any character stream
b) A character stream whose source is an array
c) A character stream whose source is character array
d) A character stream whose source is String only
View Answer

Answer: d
Explanation: The StringReader can only work with the string type data. Even if a character array is given, it might produce some errors in code. Hence only the string values can be handled properly.

12. Which exception handler can be used when character encoding is not supported?
a) UnsupportedException
b) UnsupportedEncodingException
c) SupportException
d) EncodingException
View Answer

Answer: b
Explanation: The encoding that is unsupported in a system can be handled. The exception handler is UnSupportedEncodingException class. An object of this class can be created which will catch the exception and handle it.

13. PushBackReader allows the streams to be pushed back to the stream.
a) True
b) False
View Answer

Answer: a
Explanation: The PushBackReader allows the character streams handling. The main feature is that the stream can be pushed back to the stream. This is used in special cases of handling input stream.

14. RandomAccessFile can be used to _______________________
a) Read from a random access file
b) Write to a random access file
c) Read and write to a random access file
d) Restricts read and write to a random access file
View Answer

Answer: c
Explanation: The RandomAccessFile class instance can be created to handle input and output operations to a random access file. It first checks the permissions on the file and then any required operation can be done on a random access file. Comparatively faster than other files access.

15. Which among the following is a serialization descriptor for any class?
a) StreamClass
b) ObjectStreamClass
c) ObjectStream
d) StreamObjectClass
View Answer

Answer: b
Explanation: The ObjectStreamClass object can be created to handle serializations. The class is provided specially for the serializations. It is descriptor like we have a file descriptor to handle/access files.

Sanfoundry Global Education & Learning Series – Object Oriented Programming (OOPs).

To practice all areas of Object Oriented Programming (OOPs) using C++, here is complete set of 1000+ Multiple Choice Questions and Answers.

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