iGET

Java Programming - MCQ Practice Questions

Java interviews and campus tests lean heavily on object oriented behaviour rather than API recall. This set covers inheritance and polymorphism, interfaces and abstract classes, the collections framework, exception handling, multithreading, string handling, and JVM basics such as garbage collection. Output based questions are included because they expose the gaps that theory questions hide.

951 questions | 100% Free

Q.21Easy

Which of the following correctly demonstrates chaining multiple filters in Java I/O?

Q.22Medium

A serialized object contains a field marked as 'transient'. What happens to this field when the object is deserialized?

Q.23Hard

In a multi-threaded environment, which stream class provides thread-safe read/write operations without external synchronization?

Q.24Easy

What will be the output of reading from a ByteArrayInputStream initialized with bytes [65, 66, 67] after calling read() three times?

Q.25Hard

A developer uses PipedInputStream and PipedOutputStream in the same thread. What will happen?

Q.26Medium

Which statement about ObjectOutputStream.reset() is correct?

Q.27Medium

When implementing Externalizable interface, which method is mandatory?

Q.28Easy

A RandomAccessFile is opened with mode 'r'. Which operation will throw an exception?

Q.29Medium

In a CSV file processing application, why is BufferedReader preferred over FileReader for reading large files?

Q.30Medium

What is the serialVersionUID used for in Java serialization?

Q.31Hard

A program reads a 1 GB binary file and needs to modify specific bytes at random positions. Which class is most suitable?

Q.32Medium

What happens when you write to a closed PrintWriter?

Q.33Hard

In Java NIO, what is the primary advantage of FileChannel over traditional streams?

Q.34Medium

Which scenario would require using a SequenceInputStream?

Q.35Medium

A file contains 1000 lines. Using BufferedReader.readLine() repeatedly reads all lines. What is the time complexity?

Q.36Hard

For a real-time log file monitoring application, which approach is most suitable?

Q.37Easy

Which class in Java I/O streams is used to read primitive data types from a binary file?

Q.38Easy

What is the purpose of the flush() method in PrintWriter?

Q.39Easy

Which of the following is a character-based stream in Java?

Q.40Medium

In a real-time application processing sensor data streams, which buffering approach would minimize latency?