Read Also: Top 20 MCQ Questions On Strings And Vectors In Java
1. The …………………… package contains a large number of stream classes that provide capabilities for processing all types of data.
A) java.awt
B) java.io
C) java.util
D) java.net
2. State whether the following statements about the stream in Java.
i) The two basic streams used are the input and output streams.
ii) Filters are used to read data from one stream and write it to another stream.
A) True, True
B) True, False
C) False, True
D) False, False
3. The InputStream class defines methods for performing input functions such as
i) reading bytes ii) closing streams
iii) skipping ahead in a stream iv) flushing streams
A) ii, iii and iv only
B) i, ii and iii only
C) i, iii and iv only
D) All i, ii, iii and iv
4. The OutputStreams includes methods that are designed to perform the following tasks.
i) closing streams ii) flushing streams
iii) reading bytes iv) writing bytes
A) ii, iii and iv only
B) i, ii and iii only
C) i, ii and iv only
D) All i, ii, iii and iv
5. Which of the following method(s) not included in InputStream class.
A) available( )
B) reset( )
C) flush( )
D) close( )
6. Which of the following methods not included in OutputStream class.
A) write( )
B) skip( )
C) close( )
D) flush( )
7. The class DataInputStream extends …………………….. and implements the interface DataInput.
A) FileInputStream
B) SequenceInputStream
C) FilterInputStream
D) InputStream
8. The method …………………., force writes whenever the data accumulates in the output stream.
A) write( )
B) flush( )
C) read( )
D) reset( )
9. The DataInputStream and DataOutputStream classes are …………………….. streams that allow the reading and writing of Java primitive data types.
A) file
B) sequence
C) object
D) filter
10. The ……………………… class provides the capacity to read primitive data types from an input stream.
A) pushbackInputStream
B) DataInputStream
C) BufferedInputStream
D) PipeInputStream
11. Which of the following is/are the methods of the DataOutputStream class.
i) void writeChar(intV) ii) void writeLong(longV)
iii) void writeInt(intV) iv) int size( )
A) ii, iii and iv only
B) i, ii and iii only
C) i, ii and iv only
D) All i, ii, iii and iv
12. DataInput is
A) an abstract class defined in java.io
B) a class we can use to read primitive data types
C) an interface that defines methods to open files
D) an interface that defines methods to read primitives data types
13. Which exception is thrown by the read( ) method of InputStream class.
A) Exception
B) IOException
C) ReadException
D) File Not Found Exception
14. The ……………………… method of the BufferedReader class is used for reading lines of text from the console, the file or other input streams.
A) read( )
B) read(byte[]b)
C) readLine( )
D) readByte( )
15. ……………………. class is used to increase the efficiency of input operations.
A) DataInputStream
B) FileInputStream
C) BufferedInputStream
D) PipeInputStream
16. State whether the following statements about DataInputStream class are True.
i) readBoolean( ) reads one byte and returns true if that byte is nonzero, false if it is zero.
ii) readByte( ) reads a byte as an 8-bit signed value.
iii) readChar( ) reads a unicode character.
A) True, False, True
B) False, True, False
C) True, False, False
D) True, True, True
17. The ……………………. class implements the DataInput and DataOutput interfaces for performing I/O using the primitive data types.
A) RandomAccessFile
B) OutputStream Reader
C) InputStreamReader
D) DataOutputStream
18. The class ………………………. is a subclass of object class which can be used for breaking up a stream of text from an input text file into meaningful pieces.
A) Stream Tokenizer
B) RandomAccessFile
C) InputStreamReader
D) DataOutputStream
19. Combining two or more input streams into a single input stream can be achieved using the ………………. class.
A) SequenceOutputStream
B) BufferedInputStream
C) BufferedOutputStream
D) SequenceInputStream
20. ……………….. streams provide functionally for threads to communicate and exchange data between them.
A) Object
B) Piped
C) Pushback
D) Filtered
Answers
1. B) java.io
2. A) True, True
3. B) i, ii and iii only
4. C) i, ii and iv only
5. C) flush( )
6. B) skip( )
7. C) FilterInputStream
8. B) flush( )
9. D) filter
10. B) DataInputStream
11. B) i, ii and iii only
12. D) an interface that defines……..
13. B) IOException
14. C) readLine( )
15. C) BufferedInputStream
16. D) True, True, True
17. A) RandomAccessFile
18. A) Stream Tokenizer
19. D) SequenceInputStream
20. B) Piped
Read Next:Top 20 Objective Questions On Applets In Java
Read More: Java MCQ Questions
Comments are closed.