iGET

Java Programming - MCQ Practice Questions

Practice free Java Programming multiple-choice questions with detailed answers and explanations. Perfect for competitive exam preparation.

951 questions | 100% Free

Q.221Medium

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

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

Which collection class implements NavigableMap interface?

Q.224Medium

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

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

Q.226Medium

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

Q.227Medium

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

Q.228Medium

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

Q.229Medium

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

Q.230Hard

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

Q.231Hard

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

Q.232Easy

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

Q.233Hard

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

Q.234Easy

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

Q.235Easy

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

Q.236Easy

Which collection class is synchronized by default?

Q.237Easy

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

Q.238Easy

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

Q.239Medium

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

Q.240Medium

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