nerdexam
Oracle

1Z0-900 · Question #60

Your class requires multiple resources defined, as shown in the following: Which annotation do you use to group multiple @Resource declarations together for class-based injection, replacing <XXXX>…

The correct answer is B. @Resource. In modern Java EE / Jakarta EE (with Java 8+ repeating annotations support), @Resource itself is marked as @Repeatable, meaning you apply it multiple times directly on the class - the <XXXX> placeholder is simply replaced with another @Resource declaration, not a wrapper…

Understand Java EE Architecture

Question

Your class requires multiple resources defined, as shown in the following:

Which annotation do you use to group multiple @Resource declarations together for class-based injection, replacing <XXXX> in the code above?

Options

  • A@Resources
  • B@Resource
  • C@ResourceGroup
  • D@ResourceCollection

How the community answered

(19 responses)
  • B
    95% (18)
  • D
    5% (1)

Explanation

In modern Java EE / Jakarta EE (with Java 8+ repeating annotations support), @Resource itself is marked as @Repeatable, meaning you apply it multiple times directly on the class - the <XXXX> placeholder is simply replaced with another @Resource declaration, not a wrapper. Option A (@Resources) is the old pre-Java 8 container annotation used to manually wrap multiple @Resource annotations; it still exists but is no longer the annotation you write explicitly when using repeating annotation syntax. Options C (@ResourceGroup) and D (@ResourceCollection) do not exist in the Java EE / Jakarta EE specification at all.

Memory tip: Think of it as "repeat what you know" - since Java 8, you just keep writing @Resource as many times as you need; the compiler handles the container (@Resources) behind the scenes automatically.

Topics

#@Resource annotation#Dependency injection#Resource management#Class-based injection

Community Discussion

No community discussion yet for this question.

Full 1Z0-900 Practice