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
Which method is used to remove an element from ArrayList while iterating?
What is the load factor in HashMap? What is its default value?
What is the time complexity of add() operation in TreeSet?
Which of the following is thread-safe?
What does the Comparable interface do in Collections Framework?
Which collection is best for frequent insertions and deletions in the middle?
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?
Which interface provides sorted ordering in Collections Framework?
Which collection class is synchronized and legacy?
Which of the following statements about Queue interface is correct?
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());
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); }
What is the output of the following code? List<String> list = Arrays.asList("A", "B", "C"); list.add("D"); System.out.println(list.size());
What is the time complexity of contains() operation in HashSet?
Which of the following is a fail-fast iterator behavior?
Consider a scenario where you need fast random access and frequent insertions in the middle. Which collection is most suitable?
What does the removeIf() method in Collection interface do?
What is the time complexity of add() operation in ArrayList?
Which collection maintains insertion order and also provides thread-safety?
What is the difference between Iterator and ListIterator?