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

Which of the following correctly implements the Factory Design Pattern principle in OOP?

Q.42Hard

In a banking system, Account is a parent class with method withdraw(). SavingsAccount and CurrentAccount both override it. A programmer writes: List<Account> accounts = new ArrayList<>(); accounts.add(new SavingsAccount()); accounts.add(new CurrentAccount()); for(Account a : accounts) a.withdraw(1000); Which concept is primarily demonstrated here?

Q.43Hard

Which method throws ConcurrentModificationException when collection is modified during iteration?

Q.44Hard

What is the initial capacity and growth strategy of ArrayList?

Q.45Hard

What is the worst-case time complexity of HashMap.get() when hash collisions occur?

Q.46Hard

What is the behavior of get() method in LinkedHashMap with accessOrder=true?

Q.47Hard

Consider implementing a Comparator for custom sorting in reverse order. Which approach is correct? List<Integer> list = Arrays.asList(5, 2, 8, 1);

Q.48Hard

In a multi-threaded environment, if you need a thread-safe list that allows concurrent reads, which is optimal?

Q.49Hard

In Java 16+, what feature improved collection performance by allowing value-based classes?

Q.50Hard

What is the behavior when concurrent modification occurs during iteration in ConcurrentHashMap vs HashMap?

Q.51Hard

What is the time complexity of subList() operation in ArrayList?

Q.52Hard

Which stream terminal operation preserves encounter order in parallel streams for Collections?

Q.53Hard

What is the worst-case time complexity of QuickSort when used with Collections.sort()?

Q.54Hard

In a scenario where you need to maintain a mapping with LRU (Least Recently Used) eviction policy, which class should be extended?

Q.55Hard

What does the spliterator() method introduced in Java 8 provide over Iterator?

Q.56Hard

What does the containsAll() method of Collection return for an empty collection?

Q.57Hard

How does Java 8+ handle hash collisions in HashMap differently?

Q.58Hard

What is the behavior of WeakHashMap when a key is no longer strongly referenced?

Q.59Hard

Which of these operations is guaranteed to be atomic in ConcurrentHashMap?

Q.60Hard

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