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

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

Q.2Easy

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

Q.3Easy

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

Q.4Easy

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

Q.5Easy

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

Q.6Easy

Which method reads a complete line from a BufferedReader?

Q.7Easy

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

Q.8Easy

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

Q.9Easy

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

Q.10Easy

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

Q.11Easy

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

Q.12Easy

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

Q.13Easy

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

Q.14Easy

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

Q.15Easy

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

Q.16Easy

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

Q.17Easy

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

Q.18Easy

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

Q.19Easy

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

Q.20Easy

Which stream class is used to write primitive data types in binary format?