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

What is the primary difference between throw and throws in Java exception handling?

Q.142Easy

Which of the following is a character stream class in Java?

Q.143Easy

Which method is used to read a single byte from a FileInputStream?

Q.144Easy

What is the purpose of the flush() method in output streams?

Q.145Easy

What is the return type of FileInputStream's read() method?

Q.146Easy

What exception is thrown when a file is not found while creating FileInputStream?

Q.147Easy

Which method reads a complete line from a BufferedReader?

Q.148Easy

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

Q.149Easy

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

Q.150Easy

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

Q.151Easy

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

Q.152Easy

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

Q.153Easy

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

Q.154Easy

Which class would you use to read and write at arbitrary positions in a file?

Q.155Easy

What happens when you attempt to read from a closed InputStream?

Q.156Easy

Which class in Java is used to read primitive data types from a binary stream?

Q.157Easy

What is the output of the following code?
FileReader fr = new FileReader("test.txt");
int data = fr.read();
System.out.println(data);

Q.158Easy

Which interface must be implemented by a class to make its objects serializable?

Q.159Easy

What does the flush() method do in output streams?

Q.160Easy

Which class provides buffering capability to improve I/O performance?