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

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

Q.82Medium

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

Q.83Medium

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

Q.84Medium

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

Q.85Medium

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

Q.86Medium

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

Q.87Hard

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

Q.88Hard

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

Q.89Hard

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.90Hard

What is the primary advantage of PushbackInputStream?

Q.91Easy

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

Q.92Medium

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

Q.93Medium

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

Q.94Medium

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.95Easy

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.96Hard

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