Why: For collections, the element type is used and the word List is appended. Strings in a collection give stringList.
5. How does the name generation find the element type of a collection?
Why: The logic uses the first element to decide the type. This is why the collection must not be empty.
6. An array of strings is added without a name. What attribute name is generated?
model.addAttribute(new String[]{"a", "b"});
Why: Arrays follow the same rule as collections. The element type is used and List is appended, so the name is stringList.
7. What attribute name is generated for an object of this custom class?
class ProductDetail { }
model.addAttribute(new ProductDetail());
Why: The short class name is used with the first letter in lowercase, so the name is productDetail.
8. What are the generated names for a, b and c, in this order?
Object a = new TreeMap<>();
Object b = new HashSet<>(List.of("x", "y"));
Object c = 'z';
Why: A map is not treated like a collection, so it uses its short class name: treeMap. A set of strings becomes stringList. A char is boxed to Character, giving character.
9. What will the page show for the three expressions?