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

Which of the following statements about Queue interface is correct?

Q.222Medium

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

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.224Easy

Which collection class implements NavigableMap interface?

Q.225Medium

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.226Easy

In the context of streams and collections, which method returns a Sequential Stream in Java 8+?

Q.227Medium

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

Q.228Medium

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

Q.229Medium

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

Q.230Medium

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

Q.231Hard

What is the behavior of get() method in LinkedHashMap with accessOrder=true?

Q.232Hard

Consider implementing a Comparator for custom sorting in reverse order. Which approach is correct? List<Integer> list = Arrays.asList(5, 2, 8, 1);

Q.233Easy

Which Collection method was introduced in Java 9 to create immutable collections?

Q.234Hard

In a multi-threaded environment, if you need a thread-safe list that allows concurrent reads, which is optimal?

Q.235Easy

Which of the following Collection interfaces does NOT support duplicate elements?

Q.236Easy

What is the default initial capacity of a HashMap in Java?

Q.237Easy

Which collection class is synchronized by default?

Q.238Easy

What does the poll() method return when called on an empty Queue?

Q.239Easy

Which of the following correctly represents the hierarchy of Collection framework?

Q.240Medium

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