iGET

Java Programming - MCQ Practice Questions

Practice free Java Programming multiple-choice questions with detailed answers and explanations. Perfect for competitive exam preparation.

951 questions | 100% Free

Q.61Medium

Consider a scenario where you need to read a line from a file. Which class would be most efficient?

Q.62Easy

Which stream class is used to write primitive data types in binary format?

Q.63Medium

In a multi-threaded application, what is a concern when sharing streams between threads?

Q.64Medium

What is the difference between InputStreamReader and FileReader?

Q.65Medium

Consider processing a 1GB file. Which approach would be most memory-efficient?

Q.66Medium

What does the available() method in InputStream return?

Q.67Medium

In Java NIO, which class is used for channel-based I/O?

Q.68Medium

What is the correct way to ensure resources are properly closed in Java 7+?

Q.69Hard

Given the code: PrintWriter pw = new PrintWriter(new FileWriter("file.txt")); What issue might occur?

Q.70Medium

What happens when you create a FileOutputStream with an existing file?

Q.71Hard

Which approach would you use to read and write objects to a file efficiently in a production application?

Q.72Hard

In a log aggregation system, what is the primary advantage of using RandomAccessFile over sequential streams?

Q.73Easy

Which of the following is NOT a character stream class in Java?

Q.74Medium

What is the default buffer size used by BufferedInputStream?

Q.75Easy

Which interface must be implemented to make an object serializable in Java?

Q.76Easy

In Java, what is the primary purpose of the flush() method in output streams?

Q.77Medium

Which class is used to read primitive data types and strings from a binary stream?

Q.78Easy

What will be the output of the following code? FileOutputStream fos = new FileOutputStream("test.txt", true); What does the 'true' parameter indicate?

Q.79Medium

Which of the following best describes the relationship between InputStream and Reader classes?

Q.80Medium

In a scenario where you need to write formatted output (like printf), which class should be used?