iGET

Java Programming - MCQ Practice Questions

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

958 questions | 100% Free

Q.581Easy

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

Q.582Medium

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

Q.583Medium

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

Q.584Medium

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

Q.585Medium

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

Q.586Medium

What is the purpose of the serialVersionUID field in a serializable class?

Q.587Medium

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

Q.588Medium

What happens if you try to read from a closed stream?

Q.589Medium

Which class wraps a byte stream to handle character encoding/decoding?

Q.590Medium

In the try-with-resources statement, what happens to resources automatically?

Q.591Hard

What is the main advantage of using RandomAccessFile over sequential streams?

Q.592Hard

When deserializing an object, which methods are called in order?

Q.593Hard

Consider a scenario where you need to read a large binary file efficiently without loading it entirely into memory. Which approach combines best practices?

Q.594Hard

What is the primary advantage of PushbackInputStream?

Q.595Easy

Which of the following classes is used to read primitive data types from an input stream in Java?

Q.596Medium

In a file I/O operation, you need to write objects to a file and later retrieve them. Which approach is most appropriate?

Q.597Medium

What will happen if you attempt to serialize a class that contains a non-serializable instance variable without declaring it as transient?

Q.598Medium

Consider a scenario where you're processing a 5GB log file and need to count specific error messages. Which I/O strategy would be most memory-efficient?

Q.599Easy

Which interface must a class implement to be eligible for serialization in Java, and what is the significance of implementing it with no abstract methods?

Q.600Hard

In a multi-threaded application, multiple threads are writing to the same file simultaneously using FileOutputStream. What is the primary issue and best solution?