← 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 effect of applying @Deprecated to an API element in Java 11?

    Answer: The compiler emits a warning when the element is used, and it appears in Javadoc as deprecated

    @Deprecated causes the compiler to issue a deprecation warning at use sites and marks the element in Javadoc.

  2. In Java 11, @Deprecated gained which additional element to indicate that the deprecated API may be removed in a future release?

    Answer: forRemoval = true

    The forRemoval=true element, added in Java 9, signals that the deprecated API is planned for future removal and triggers an even stronger compiler warning.

  3. Which statement about annotation inheritance is accurate?

    Answer: @Inherited only works for class-level annotations, not method-level ones

    @Inherited only propagates class-level annotations from superclass to subclass; it does not apply to interface implementations or method-level annotations.

  4. Which of the following annotation element types allows you to embed one annotation type inside another?

    Answer: Another annotation type

    An annotation element can itself be another annotation type, enabling composition of annotations.

  5. What compile-time error occurs when you use @Override on a method that does not actually override a superclass or interface method?

    Answer: Compile error: method does not override or implement a method from a supertype

    @Override causes a compile-time error if the annotated method doesn't match any method signature in a superclass or implemented interface.

  6. RetentionPolicy.CLASS means annotations are stored in the .class file but NOT available at runtime. Which default retention policy applies when @Retention is omitted?

    Answer: CLASS

    If @Retention is not specified, the default retention policy is CLASS — the annotation is recorded in the bytecode but not accessible via reflection at runtime.

  7. Which of the following correctly uses a type annotation in Java 11?

    Answer: public @NotNull String getName()

    For a method return type annotation, the annotation is placed immediately before the type it annotates: public @NotNull String getName().