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

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

Q.42Medium

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

Q.43Medium

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

Q.44Medium

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

Q.45Medium

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

Q.46Medium

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

Q.47Medium

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

Q.48Medium

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

Q.49Medium

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

Q.50Medium

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?