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
Consider a scenario: You need a data structure that maintains elements in sorted order and allows fast insertion/deletion. Which is optimal?
What exception is thrown by Iterator.next() when there are no more elements?
Which method of NavigableSet returns the greatest element strictly less than the given element?
What is the output of Collections.frequency(list, null) if list contains null elements?
What is the time complexity of get() operation in TreeMap?
What is the difference between ArrayList and Vector?
Which method of PriorityQueue returns the element without removing it?
What exception is thrown when you try to add a null value to a TreeSet?
Which Collections utility method creates an immutable empty list?
In what scenario would you use a ConcurrentHashMap instead of HashMap?
Consider: Set<Integer> set = new HashSet<>(Arrays.asList(1,2,3,2,1)); System.out.println(set.size()); What is the output?
Which method in NavigableMap returns a view of the map in descending order?
What is the advantage of using LinkedList over ArrayList for frequent insertions at the beginning?
Which method is used to remove all elements from a Collection that satisfy a given predicate?
What is the key difference between TreeSet and HashSet?
Which interface should be implemented to define custom sorting in Collections.sort()?
What does Collections.unmodifiableList() return?
Which collection allows duplicate keys in Java?
What is the initial capacity of a HashMap in Java?
What happens when you add a null key to a HashMap?