This set of Object Oriented Programming (OOPs) Multiple Choice Questions & Answers (MCQs) focuses on “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
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 flexibility to make the programs more user friendly.
2. IO class provides input and output through ______________________
a) Data streams
c) File system
d) Data streams, serialization and file system
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?
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.
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
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
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.
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
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 use of permissions
c) This class is used to represent device access permissions
d) This class is used to represent file access permissions
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.
8. Which class among the following makes incorrect assumptions?
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
Explanation: The Reader class is an abstract class which 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?
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
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.
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.
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
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?
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), here is complete set of 1000+ Multiple Choice Questions and Answers.