← 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 RetentionPolicy value causes an annotation to be discarded by the compiler and never stored in the .class file?

    Answer: SOURCE

    RetentionPolicy.SOURCE annotations are stripped out during compilation and do not appear in the bytecode.

  2. Which method of java.lang.reflect.AnnotatedElement returns all annotations directly present on an element, excluding inherited ones?

    Answer: getDeclaredAnnotations()

    getDeclaredAnnotations() returns only annotations directly present on the element, ignoring @Inherited annotations from superclasses.

  3. An annotation element type must be one of the permitted types. Which of the following is NOT a permitted annotation element type?

    Answer: A generic type parameter (e.g., T)

    Annotation element types must be primitives, String, Class, enum, another annotation type, or arrays thereof — generic type parameters are not permitted.

  4. What happens if you annotate an annotation type with @Target(ElementType.TYPE)?

    Answer: The annotation can be applied to classes, interfaces, enums, and annotation types

    ElementType.TYPE covers all type declarations: classes, interfaces, enums, and annotation types.

  5. Which built-in Java annotation suppresses compiler warnings for unchecked generics casts?

    Answer: @SuppressWarnings("unchecked")

    @SuppressWarnings("unchecked") tells the compiler to suppress warnings related to unchecked type casts and raw type usage.

  6. The @FunctionalInterface annotation is declared with which retention policy?

    Answer: RUNTIME

    @FunctionalInterface has RUNTIME retention, allowing frameworks to inspect it via reflection.

  7. Which of the following annotation declarations is syntactically INVALID?

    Answer: @interface MyAnno extends java.lang.annotation.Annotation {}

    Annotation types implicitly extend java.lang.annotation.Annotation; explicitly writing 'extends' in the declaration is a compile error.