1
Loading subject content…
Loading subject content…
Loading practice questions…
What is the output of the following program?
public class Main {
public static void main(String[] args) {
java.util.List<Integer> l = new java.util.ArrayList<>(java.util.List.of(3, 1, 2));
java.util.Collections.sort(l);
System.out.println(l);
}
}What is the output of the following program?
import java.util.*;
public class Main {
public static void main(String[] args) {
List<Integer> nums = new ArrayList<>(List.of(1, 2, 3, 4));
nums.removeIf(n -> n % 2 == 0);
System.out.println(nums);
}
}What is the output of the following program?
import java.util.*;
public class Main {
public static void main(String[] args) {
Queue<String> q = new LinkedList<>();
q.offer("x"); q.offer("y");
System.out.println(q.poll() + q.size());
}
}What is the output of the following program?
public class Main {
public static void main(String[] args) {
java.util.Map<String, Integer> m = new java.util.TreeMap<>();
m.put("b", 2); m.put("a", 1); m.put("b", 5);
System.out.println(m);
}
}