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

In Java 2024-25, which enhancement improved record support in collections?

Q.62Hard

Which method in Collections can create a thread-safe Map from a non-thread-safe Map?

Q.63Hard

What is the main advantage of EnumSet over HashSet when working with Enum constants?

Q.64Hard

Consider this code: List<String> list = new CopyOnWriteArrayList<>(); list.add("A"); list.add("B"); Iterator<String> itr = list.iterator(); list.add("C"); System.out.println(itr.next());

Q.65Hard

In Java 2024, if you need a collection that automatically removes entries based on garbage collection patterns, which would you choose?

Q.66Hard

What happens when wait() is called from a thread that doesn't hold the lock?

Q.67Hard

How does the volatile keyword help in multithreading?

Q.68Hard

What will happen if you call sleep() inside a synchronized block?

Q.69Hard

Which interface allows multiple threads to access a resource with a permit system?

Q.70Hard

Consider code where Thread A holds Lock1 and waits for Lock2, while Thread B holds Lock2 and waits for Lock1. What is this scenario called?

Q.71Hard

Consider the following code. What will be the likely behavior? java synchronized void method1() { method2(); } synchronized void method2() { }

Q.72Hard

Which class is used to synchronize the execution of multiple threads at a specific point?

Q.73Hard

What is the difference between CountDownLatch and CyclicBarrier?

Q.74Hard

What will happen if a thread tries to acquire a lock it already holds while inside a synchronized method?

Q.75Hard

In a high-concurrency scenario with 2024-25 exam patterns, which Java construct provides the best lock-free approach for thread safety?

Q.76Hard

What is the primary advantage of using ReentrantLock over synchronized?

Q.77Hard

In a high-traffic web application using Java 21 Virtual Threads, what is the main performance benefit?

Q.78Hard

Which pattern should be used to safely publish data from one thread to another?

Q.79Hard

What is the purpose of ForkJoinPool in Java?

Q.80Hard

If a thread is blocked waiting for I/O, what happens when interrupt() is called on it?