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.561Medium

What is the difference between InputStreamReader and FileReader?

Q.562Medium

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

Q.563Medium

What does the available() method in InputStream return?

Q.564Medium

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

Q.565Medium

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

Q.566Hard

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

Q.567Medium

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

Q.568Hard

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

Q.569Hard

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

Q.570Easy

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

Q.571Medium

What is the default buffer size used by BufferedInputStream?

Q.572Easy

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

Q.573Easy

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

Q.574Medium

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

Q.575Easy

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

Q.576Medium

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

Q.577Medium

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

Q.578Medium

What is the difference between read() and read(byte[] b) methods in InputStream?

Q.579Medium

Which exception is thrown when you try to serialize an object that contains non-serializable fields?

Q.580Medium

You need to read a file line by line efficiently. Which approach is best?