Here are 10 essential multiple-choice questions on Java IO Basics, covering key concepts.
Question 1
Which package contains the core classes for Java IO?
java.input
java.io
java.util.io
java.file
Question 2
Which of the following is a superclass of all byte input streams?
InputStreamReader
Reader
InputStream
BufferedReader
Question 3
What does the read() method of FileInputStream return when the end of file is reached?
'0'
0
-1
null
Question 4
Which stream would you use to read character data from a file?
FileInputStream
FileReader
BufferedWriter
ObjectInputStream
Question 5
What is the primary difference between Reader and InputStream?
Reader is abstract, InputStream is not
Reader handles characters, InputStream handles bytes
InputStream handles characters, Reader handles lines
No difference
Question 6
Which class is used to write character data to a file?
FileReader
FileOutputStream
FileWriter
ObjectWriter
Question 7
What is the output of this snippet?
File f = new File("log.txt");
System.out.println(f.exists());
true if file exists
Always true
Always false
Compilation error
Question 8
Which method is used to close an IO stream in Java?
stop()
flush()
shutdown()
close()
Question 9
What happens if FileInputStream is given a non-existent file?
Returns null
Creates a new file
Throws FileNotFoundException
Ignores the error
Question 10
Which is the correct hierarchy?
FileReader → Reader → Writer
FileInputStream → InputStream → OutputStream
FileWriter → Writer → OutputStream
FileReader → InputStream → Reader
There are 10 questions to complete.