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.21Hard

What is the behavior of ReentrantReadWriteLock when multiple threads perform read operations?

Q.22Hard

Which scenario can lead to livelock in multithreading?

Q.23Hard

In a ForkJoinPool, what is the primary advantage over ExecutorService for recursive tasks?

Q.24Hard

What is the output of the following code? Thread t = new Thread(() -> { throw new RuntimeException("Error"); }); t.setUncaughtExceptionHandler((thread, ex) -> System.out.println("Caught")); t.start();

Q.25Hard

Which statement about StampedLock is TRUE?

Q.26Hard

In the context of Java 21 Virtual Threads, what is a major limitation of traditional threading that Virtual Threads solve?

Q.27Hard

Consider a ThreadLocal variable initialized in a thread pool executor with 10 threads. If the same thread is reused from the pool for a different task, what is the state of its ThreadLocal variable?

Q.28Hard

A high-frequency trading system uses AtomicInteger for concurrent counter updates. However, performance degrades as more threads access the same counter. What is the primary cause and best solution?