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

Which of the following statements about Queue interface is correct?

Q.22Medium

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

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

Which collection class implements NavigableMap interface?

Q.25Medium

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

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

Q.27Medium

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

Q.28Medium

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

Q.29Medium

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

Q.30Medium

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

Q.31Hard

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

Q.32Hard

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

Q.33Easy

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

Q.34Hard

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

Q.35Easy

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

Q.36Easy

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

Q.37Easy

Which collection class is synchronized by default?

Q.38Easy

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

Q.39Easy

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

Q.40Medium

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