nerdexam
Oracle

1Z0-819 · Question #68

@Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface AuthorInfo { String author() default ""; String date(); String[] comments() default {}; } Which two are correct?…

The correct answer is B. public class Hello { @AuthorInfo(date="1-1-2020", comments="Hello") public void func () {} } E. public class Hello { @AuthorInfo(date="1-1-2020", author="Gandhi", comments={ "world" }) public void func () {} }. See the full explanation below for the reasoning.

Question

@Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface AuthorInfo { String author() default ""; String date(); String[] comments() default {}; } Which two are correct? (Choose two.)

Options

  • Apublic class Hello { @AuthorInfo(date="1-1-2020", comments={ null }) public void func () {} }
  • Bpublic class Hello { @AuthorInfo(date="1-1-2020", comments="Hello") public void func () {} }
  • Cpublic class Hello { @AuthorInfo public void func () {} }
  • Dpublic class Hello { @AuthorInfo(date="1-1-2020") public void func () {} }
  • Epublic class Hello { @AuthorInfo(date="1-1-2020", author="Gandhi", comments={ "world" }) public void func () {} }

How the community answered

(20 responses)
  • A
    5% (1)
  • B
    80% (16)
  • C
    5% (1)
  • D
    10% (2)

Community Discussion

No community discussion yet for this question.

Full 1Z0-819 Practice