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
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();
Which of the following correctly implements the Factory Design Pattern principle in OOP?
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?
Which method throws ConcurrentModificationException when collection is modified during iteration?
What is the initial capacity and growth strategy of ArrayList?
What is the worst-case time complexity of HashMap.get() when hash collisions occur?
What is the behavior of get() method in LinkedHashMap with accessOrder=true?
Consider implementing a Comparator for custom sorting in reverse order. Which approach is correct? List<Integer> list = Arrays.asList(5, 2, 8, 1);
In a multi-threaded environment, if you need a thread-safe list that allows concurrent reads, which is optimal?
In Java 16+, what feature improved collection performance by allowing value-based classes?
What is the behavior when concurrent modification occurs during iteration in ConcurrentHashMap vs HashMap?
What is the time complexity of subList() operation in ArrayList?
Which stream terminal operation preserves encounter order in parallel streams for Collections?
What is the worst-case time complexity of QuickSort when used with Collections.sort()?
In a scenario where you need to maintain a mapping with LRU (Least Recently Used) eviction policy, which class should be extended?
What does the spliterator() method introduced in Java 8 provide over Iterator?
What does the containsAll() method of Collection return for an empty collection?
How does Java 8+ handle hash collisions in HashMap differently?
What is the behavior of WeakHashMap when a key is no longer strongly referenced?
Which of these operations is guaranteed to be atomic in ConcurrentHashMap?