iGET

Java Programming - MCQ Practice Questions

Practice free Java Programming multiple-choice questions with detailed answers and explanations. Perfect for competitive exam preparation.

958 questions | 100% Free

Q.141Easy

What is the output of the following code? try { int x = ; } catch(ArithmeticException e) { System.out.println("Caught"); } finally { System.out.println("Finally"); } System.out.println("After");

Q.142Easy

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

Q.143Easy

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

Q.144Easy

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

Q.145Easy

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

Q.146Easy

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

Q.147Easy

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

Q.148Easy

Which method reads a complete line from a BufferedReader?

Q.149Easy

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

Q.150Easy

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

Q.151Easy

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

Q.152Easy

When using ObjectInputStream, what exception is thrown if the serialVersionUID doesn't match?

Q.153Easy

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

Q.154Easy

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

Q.155Easy

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

Q.156Easy

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

Q.157Easy

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

Q.158Easy

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

Q.159Easy

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

Q.160Easy

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