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.101Medium

What does the Comparable interface do in Collections Framework?

Q.102Medium

Which collection is best for frequent insertions and deletions in the middle?

Q.103Medium

Given: Map<String, Integer> map = new HashMap<>(); map.put("A", 10); map.put("B", 20); map.put("A", 30); What will be the size of map?

Q.104Medium

Which interface provides sorted ordering in Collections Framework?

Q.105Medium

Which collection class is synchronized and legacy?

Q.106Medium

Which of the following statements about Queue interface is correct?

Q.107Medium

What will be the result of executing this code? PriorityQueue<Integer> pq = new PriorityQueue<>(); pq.add(5); pq.add(3); pq.add(7); System.out.println(pq.peek());

Q.108Medium

Consider the following code. What is the behavior? Collection<String> col = new ArrayList<>(); col.add("Java"); Iterator<String> it = col.iterator(); while(it.hasNext()) { String s = it.next(); col.remove(s); }

Q.109Medium

What is the output of the following code? List<String> list = Arrays.asList("A", "B", "C"); list.add("D"); System.out.println(list.size());

Q.110Medium

What is the time complexity of contains() operation in HashSet?

Q.111Medium

Which of the following is a fail-fast iterator behavior?

Q.112Medium

Consider a scenario where you need fast random access and frequent insertions in the middle. Which collection is most suitable?

Q.113Medium

What does the removeIf() method in Collection interface do?

Q.114Medium

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

Q.115Medium

Which collection maintains insertion order and also provides thread-safety?

Q.116Medium

What is the difference between Iterator and ListIterator?

Q.117Medium

Consider a scenario: You need a data structure that maintains elements in sorted order and allows fast insertion/deletion. Which is optimal?

Q.118Medium

What exception is thrown by Iterator.next() when there are no more elements?

Q.119Medium

Which method of NavigableSet returns the greatest element strictly less than the given element?

Q.120Medium

What is the output of Collections.frequency(list, null) if list contains null elements?