Answer all 10 questions, then submit to see your score.
1. Which statement correctly describes an interface's static method?
2. What does this print?
List<String> names = new ArrayList<>(); names.add("Sam"); System.out.println(names.getClass().getSimpleName());
3. Which of the following is identified as a common mistake in this lesson?
4. Which of the following will fail to compile?
try { int[] arr = new int[2]; System.out.println(arr[5]); } catch (RuntimeException e) { System.out.println("runtime"); } catch (ArrayIndexOutOfBoundsException e) { System.out.println("array"); }
5. Why can the exact same lambda expression `(a, b) -> a.length() - b.length()` be assigned to both `Comparator<String>` and `BiFunction<String, String, Integer>`?
6. How does `Collectors.partitioningBy(predicate)` differ from `Collectors.groupingBy()` in terms of guaranteed map keys?
7. What does this print?
import java.util.function.BiFunction; import java.util.function.Function; public class Demo { public static void main(String[] args) { Function<String, Integer> parse = Integer::parseInt; BiFunction<String, String, Boolean> starts = String::startsWith; System.out.println(parse.apply("42")); System.out.println(starts.apply("hello", "he")); } }
8. Why does extending `Throwable` directly (instead of `Exception` or `RuntimeException`) count as a common mistake?
9. Which of the following are true about `ArrayDeque` vs. `LinkedList` performance, according to this lesson? (Select all that apply)
10. Which of the following are true about iterating a `Map` when you need both the key and the value? (Select all that apply)