← All 1Z0-819 Flashcard Decks

Annotations Flashcards

7 cards from real 1Z0-819 practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.

Read the first 7 Annotations flashcards as text
  1. What is the purpose of the @Native meta-annotation in Java?

    Answer: It indicates that a constant field may be referenced from native code

    @Native (java.lang.annotation.Native) marks a constant-valued field that may be referenced from native code, hinting to tools to generate header files.

  2. Which annotation was introduced in Java 9 to indicate that a module exports a package for use only by specific other modules?

    Answer: None — this is a module-info.java keyword, not an annotation

    Qualified exports in module-info.java are declared with the 'exports ... to ...' syntax, not with a Java annotation.

  3. Given a repeatable annotation @Tag and its container @Tags, which method should you use to retrieve all @Tag instances from a method at runtime?

    Answer: method.getAnnotationsByType(Tag.class)

    getAnnotationsByType(Tag.class) transparently unwraps the container and returns all repeated @Tag annotations as a flat array.

  4. Which of the following correctly defines a single-element annotation where the element is named 'value'?

    Answer: public @interface Timeout { long value(); }

    The special element name 'value' allows callers to omit the element name: @Timeout(500) instead of @Timeout(value=500).

  5. An annotation processor that generates new source files implements which interface from javax.annotation.processing?

    Answer: Processor

    javax.annotation.processing.Processor is the interface annotation processors implement; AbstractProcessor provides a convenient base class.

  6. What does @SafeVarargs guarantee when applied to a method?

    Answer: The method does not perform potentially unsafe operations on its varargs parameter

    @SafeVarargs is a programmer assertion that the method body does not perform heap-polluting operations on the generic varargs parameter.

  7. Which ElementType value must be included in @Target for an annotation to be usable as a type annotation (e.g., @NotNull List)?

    Answer: ElementType.TYPE_USE

    ElementType.TYPE_USE (added in Java 8) allows an annotation to appear wherever a type is used, including generic type arguments.