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

A system has classes: Vehicle -> Car -> ElectricCar. If Vehicle.start() is overridden in Car and again in ElectricCar, what is the output of: Vehicle v = new ElectricCar(); v.start();

Q.42Hard

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

Q.43Hard

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

Which method throws ConcurrentModificationException when collection is modified during iteration?

Q.45Hard

What is the initial capacity and growth strategy of ArrayList?

Q.46Hard

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

Q.47Hard

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

Q.48Hard

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

Q.49Hard

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

Q.50Hard

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

Q.51Hard

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

Q.52Hard

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

Q.53Hard

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

Q.54Hard

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

Q.55Hard

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

Q.56Hard

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

Q.57Hard

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

Q.58Hard

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

Q.59Hard

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

Q.60Hard

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