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

Which method is used to remove an element from ArrayList while iterating?

Q.2Medium

What is the load factor in HashMap? What is its default value?

Q.3Medium

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

Q.4Medium

Which of the following is thread-safe?

Q.5Medium

What does the Comparable interface do in Collections Framework?

Q.6Medium

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

Q.7Medium

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

Which interface provides sorted ordering in Collections Framework?

Q.9Medium

Which collection class is synchronized and legacy?

Q.10Medium

Which of the following statements about Queue interface is correct?

Q.11Medium

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

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

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

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

Q.15Medium

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

Q.16Medium

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

Q.17Medium

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

Q.18Medium

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

Q.19Medium

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

Q.20Medium

What is the difference between Iterator and ListIterator?