Assignment7
TYPE OF QUESTION: MCQ
Number of questions: 10 Total mark: 10 × 1 = 10
QUESTION 1:
Which of the following streams contains the classes which can work on character stream?
a. InputStream
b. OutputStream
c. FileReader
d. FileWriter
Correct Answer: c, d
Detailed Solution:
Note: InputStream and OutputStream classes work on byte streams.
QUESTION 2:
Which of the following methods help in clearing the contents of the buffer:
a. flush()
b. clear()
c. close()
d. exit()
Correct Answer: a
Detailed Solution:
Note: Clear() and exit() are not any valid methods defined in any class in java.io package. The
close() method closed a stream.
, QUESTION 3:
In which Java APIs the classes for handling all IO-streams are defined?
a. java.lang
b. java.util
c. java.io
d. java.awt
Correct Answer: b
Detailed Solution:
java.io package is meant for handling io-streams in Java program.
QUESTION 4:
Which of the following statements is/ are NOT true?
a. While you are creating an instance of File class, and if you do not use the file naming
according to the convention of the local machine, the constructor will throw an exception
of class IOException.
b. A File object can be opened for both reading and writing simultaneously.
c. When you create an object of Fileclass for writing, if the corresponding file does not exist
on the local file system, then it will be created.
d. Closing operation of a File object never faces any run-time error and hence need not to be
placed under try-catch block.
Correct Answer: b
Detailed Solution:
You can open a File object either in read or write mode, but not both.