← 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. Which meta-annotation specifies that an annotation should be recorded in the Javadoc output?

    Answer: @Documented

    @Documented causes the annotation to appear in the generated Javadoc for the annotated element.

  2. What does the @Inherited meta-annotation mean when applied to an annotation type?

    Answer: Subclasses automatically inherit the annotation from their superclass

    @Inherited causes a class-level annotation to be automatically inherited by subclasses if they do not explicitly annotate themselves.

  3. Which of the following is a valid annotation element default value declaration?

    Answer: String name() default "";

    Annotation element defaults must be constant expressions; an empty String literal is valid, but null and non-array/Class defaults have restrictions.

  4. What is a marker annotation?

    Answer: An annotation with no elements

    A marker annotation is an annotation type with no declared elements, used solely to mark a program element.

  5. Which ElementType constant allows an annotation to be placed on a formal parameter of a method?

    Answer: PARAMETER

    ElementType.PARAMETER targets method and constructor formal parameters.

  6. Given: @interface Config { String[] tags() default {}; } — which usage is correct?

    Answer: Both A and B

    A single-element array shorthand allows omitting braces, so both @Config(tags="fast") and @Config(tags={"fast","stable"}) are legal.

  7. Which statement about repeating annotations (introduced in Java 8) is correct?

    Answer: The annotation type itself must be annotated with @Repeatable pointing to its container annotation

    @Repeatable requires specifying a container annotation type whose value() element holds an array of the repeatable annotation.