iGET

Java Programming - MCQ Practice Questions

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

951 questions | 100% Free

Q.101Hard

What will be printed for this code? public class ExceptionOrder { public static void main(String[] args) { try { try { throw new RuntimeException("Inner"); } catch (Exception e) { throw new IOException("Outer"); } } catch (IOException e) { System.out.println("Caught IOException"); } catch (RuntimeException e) { System.out.println("Caught RuntimeException"); } } }

Q.102Hard

Which of the following scenarios will NOT trigger a StackOverflowError?

Q.103Hard

What happens when System.exit() is called inside try block?

Q.104Hard

Which exception is the parent class of all checked exceptions in Java (excluding RuntimeException)?

Q.105Hard

Consider a scenario where multiple catch blocks are written. What is the correct order? I. catch(FileNotFoundException e) II. catch(IOException e) III. catch(Exception e)

Q.106Hard

What will this code output? int result = 0; try { result = ; } catch(Exception e) { result = 20; return result; } finally { result = 30; } System.out.println(result);

Q.107Hard

Which of the following custom exceptions would be inappropriate to extend from RuntimeException in a banking application?

Q.108Hard

In exception chaining, what is the primary benefit?

Q.109Hard

If a finally block contains a return statement, what happens to an exception thrown in the try block?

Q.110Hard

In Java 7+, exception handling introduced 'multi-catch' feature using the pipe (|) operator. What's a limitation of multi-catch blocks?

Q.111Hard

Which scenario would cause a StackOverflowError in Java exception handling?

Q.112Hard

In Java NIO, which class replaces traditional Stream-based I/O for better performance?

Q.113Hard

What happens if you call close() multiple times on a stream?

Q.114Hard

Which of the following is true about serialization in Java?

Q.115Hard

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

Q.116Hard

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

Q.117Hard

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

Q.118Hard

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

Q.119Hard

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

Q.120Hard

For encrypting data while writing to a file, which approach is most appropriate?