exam questions

Exam 1z0-819 All Questions

View all questions & answers for the 1z0-819 exam

Exam 1z0-819 topic 1 question 133 discussion

Actual exam question from Oracle's 1z0-819
Question #: 133
Topic #: 1
[All 1z0-819 Questions]

Given this declaration:

@Target(TYPE)
@interface Resource {}

For which two kinds of declarations can the @Resource annotation be applied? (Choose two.)

  • A. An interface declaration
  • B. A local variable declaration
  • C. A class declaration
  • D. A method declaration
  • E. A field declaration
Show Suggested Answer Hide Answer
Suggested Answer: AC 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
cathDev
3 months, 3 weeks ago
Selected Answer: AC
Tested AC
upvoted 1 times
...
d7bb0b2
6 months, 1 week ago
Selected Answer: AC
A. An interface declaration: Yes, the @Resource annotation can be applied to an interface because interfaces are considered types in Java. B. A local variable declaration: No, the @Resource annotation cannot be applied to local variables because they are not considered types. C. A class declaration: Yes, the @Resource annotation can be applied to a class because classes are considered types in Java. D. A method declaration: No, the @Resource annotation cannot be applied to methods because they are not considered types. E. A field declaration: No, the @Resource annotation cannot be applied to fields because they are not considered types.
upvoted 1 times
...
d7bb0b2
7 months, 1 week ago
A & C: The @Target annotation is used to specify the kinds of program element to which an annotation type is applicable. In this case, @Target(TYPE) means that the @Resource annotation can be applied to any type declaration. In Java, a type declaration is any class, interface, enum, or annotation type declaration. Therefore, the @Resource annotation can be applied to an interface declaration (option A) and a class declaration (option C). The @Resource annotation cannot be applied to a local variable declaration (option B), a method declaration (option D), or a field declaration (option E) because these are not type declarations.
upvoted 1 times
...
duydn
8 months ago
Selected Answer: AC
A & C See: https://www.geeksforgeeks.org/java-target-annotations/
upvoted 2 times
...
MabuzaT
9 months, 1 week ago
The @Resource annotation is used to identify a class, field, or method that upon initialization, the resource will be injected. For a class-based @Resource, the "resource is looked up by the application at runtime"
upvoted 1 times
...
dilleman
9 months, 3 weeks ago
Selected Answer: AC
A and C. @Target(TYPE) can be applied to Interface, class or enum.
upvoted 3 times
...
[Removed]
10 months, 3 weeks ago
Selected Answer: AC
Straight from oracle.docs = Class, interface (including annotation type), or enum declaration
upvoted 1 times
...
Stavok
12 months ago
Selected Answer: CD
C,D,E Resource annotation is used to declare a reference to a resource; @Resource can decorate a class, a field, or a method.
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago