Java’s Input/Output operations are fundamental for handling data streams within a program. These operations enable communication between the program and external sources like files, user input, or network connections. Mastery of I/O operations is crucial for Java developers, as it underpins many real-world applications.
This collection of multiple-choice questions (MCQs) on Java I/O operations provides a practical way to reinforce knowledge and understanding of file handling, reading and writing data, and working with streams in Java. Whether for interviews or practice, these MCQs serve as a valuable resource for honing Java I/O skills and enhancing proficiency in one of the language’s key domains.
1.) Which class is used to read character-based input in Java?
2.) What is the purpose of the System.out.println() method in Java?
3.) Which class is used for reading primitive data types from an input stream in Java?
4.) In Java, which exception is typically thrown when there is an error during file input/output operations?
5.) Which method is used to close a file in Java?
6.) What is the purpose of the FileWriter class in Java?
7.) Which class is used to write formatted text to a character stream in Java?
8.) Which method is used to write an array of characters to a file in Java?
9.) Which method is used to read a line of text from an input stream in Java?
10.) Which class is used to read binary data from an input stream in Java?