Java SE 11 Developer (1Z0-819) — Question 74
Given the declaration:
@inteface Resource {
String[] value();
}
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({“Customer1”, “Customer2”})
- B. @Resource(value={{}})
- C. @Resource
- D. @Resource(“Customer1”)
- E. @Resource()
Correct answer: A, D
Explanation
The correct answers, A and D, are valid usages of the @Resource annotation, as they both provide appropriate string array values. Option B is incorrect due to the invalid syntax for the value argument, while options C and E do not specify any values, which may not meet the intended use of the annotation.