Which of the following statements about the @FunctionalInterface annotation concept is correct?
- [ ] A functional interface must necessarily be annotated with @FunctionalInterface to serve as a lambda target.
- [x] A functional interface may have exactly one abstract method, but any number of default or static methods.
- [ ] A functional interface must not override any methods from java.lang.Object.
- [ ] Abstract classes with only one abstract method are also functional interfaces.

---

What happens when a lambda expression attempts to modify a local variable of the enclosing method?
- [ ] The variable is automatically treated as atomic.
- [ ] It only works if the variable is declared as volatile.
- [x] A compiler error occurs because variables used in lambdas must be "effectively final".
- [ ] The change is only visible inside the lambda, not outside.

---

What does the 'volatile' keyword in Java guarantee regarding the threading model?
- [ ] It prevents race conditions during non-atomic operations like i++.
- [x] It ensures that write operations to the variable occur directly in main memory and are immediately visible to other threads.
- [ ] It locks the object for the duration of the access (implicit lock).
- [ ] It forces the variable to remain in the CPU cache of the respective core.

---

Which type of ThreadPool should be used when a very large number of short-lived asynchronous tasks need to be executed?
- [ ] Executors.newFixedThreadPool(10)
- [x] Executors.newCachedThreadPool()
- [ ] Executors.newSingleThreadExecutor()
- [ ] Executors.newScheduledThreadPool(1)

---

What is the main advantage of the "Initialization-on-demand holder idiom" (Bill Pugh Singleton) compared to Double-Checked Locking?
- [ ] It requires less memory space.
- [x] It utilizes the thread safety of the classloader and does not require synchronized locking or volatile.
- [ ] It allows lazy loading even for serializable objects without additional effort.
- [ ] It is the only pattern that prevents reflection attacks.

---

What is a potential disadvantage of using .parallelStream() on a LinkedList?
- [ ] The LinkedList is automatically converted into an ArrayList, which takes time.
- [ ] LinkedList does not support parallel processing.
- [x] Performance is poor because LinkedLists are difficult to split efficiently (poor Spliterator).
- [ ] It always leads to a ConcurrentModificationException.

---

Which method of CompletableFuture is used to combine two independent futures when the result of both is required for a subsequent step?
- [ ] thenApply()
- [ ] thenCompose()
- [x] thenCombine()
- [ ] applyToEither()

---

What is the fundamental difference between the Strategy and the State pattern?
- [ ] There is no difference, they are identical.
- [ ] Strategy is switched at runtime, State only at compile time.
- [x] In the State pattern, the states often know about the other states and trigger transitions themselves; in the Strategy pattern, the logic is independent.
- [ ] The State pattern is a creational pattern, Strategy is a behavioral pattern.

---

Why can you not create an array of generic types in Java (e.g., new T[10])?
- [ ] Because generics are only intended for collections.
- [ ] Because arrays do not exist at runtime.
- [x] Due to type erasure, the type information is not available at runtime to verify the type safety of the array.
- [ ] Because the JVM cannot reserve enough heap memory for generic arrays.

---

What best describes the principle of "work-stealing" in the ForkJoinPool?
- [ ] Threads steal processing time from the operating system.
- [x] Idle threads "steal" tasks from the tail of the deques (double-ended queues) of busy threads.
- [ ] Tasks are taken over from other threads based on priority.
- [ ] It is a security flaw in the Java threading model.