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

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

Q.282Medium

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

Q.283Medium

What is the default buffer size used by BufferedInputStream?

Q.284Medium

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

Q.285Medium

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

Q.286Medium

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

Q.287Medium

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

Q.288Medium

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

Q.289Medium

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

Q.290Medium

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

Q.291Medium

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

Q.292Medium

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

Q.293Medium

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

Q.294Medium

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

Q.295Medium

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

What does the executeUpdate() method return in JDBC?

Q.297Medium

Which interface is used to execute precompiled SQL statements in JDBC?

Q.298Medium

What is the primary advantage of using PreparedStatement over Statement?

Q.299Medium

Which method must be called to move cursor to the next row in ResultSet?

Q.300Medium

What is Connection pooling in JDBC?