250+ TOP MCQs on IO Class and Answers

Object Oriented Programming (OOPs) Multiple Choice Questions & Answers (MCQs) 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
Answer: c
Clarification: 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.

2. IO class provides input and output through ______________________
a) Data streams
b) Serialization
c) File system
d) Data streams, serialization and file system
Answer: d
Clarification: 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
Answer: a
Clarification: 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.

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
Answer: c
Clarification: 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
Answer: a
Clarification: 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.

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

8. Which class among the following makes incorrect assumptions?
a) LineNumberInputStream
b) LineNumberReader
c) LineReader
d) LineBuffer
Answer: a
Clarification: 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
Answer: b
Clarification: 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.

10. Which class can handle IO class interrupt?
a) ExceptionIO
b) InteruptedIO
c) InteruptedIOException
d) IOInteruptException
Answer: c
Clarification: 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
Answer: d
Clarification: 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
Answer: b
Clarification: 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
Answer: a
Clarification: 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
Answer: c
Clarification: 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
Answer: b
Clarification: 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.

Leave a Reply

Your email address will not be published. Required fields are marked *