Java SE 11 Developer (1Z0-819) — Question 187
Given the declaration:
@inteface Resource {
String value() default “Customer1”;
}
Examine this code fragment:
/* Loc1 */ class ProcessOrders { ... }
Which two annotations may be applied at Loc1 in the code fragment? (Choose two.)
Answer options
- A. @Resource(“Customer2”)
- B. @Resource(value=“Customer2”)
- C. @Resource
- D. @Resource(val=“Customer2”)
- E. @Resource({“Customer2”})
Correct answer: B, C
Explanation
The correct options are B and C. Option B correctly specifies the value using the attribute name, while option C uses the default value without any parameters. Option A is incorrect because it does not use the named parameter correctly. Option D uses an incorrect attribute name, and option E is malformed as it attempts to use an array syntax that is not supported.