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)- A5% (1)
- B80% (16)
- C5% (1)
- D10% (2)
Community Discussion
No community discussion yet for this question.