Question: Which statement about the following declarations is correct? A. None of the declarations compile. B. Only the declaration of Friend contains a compiler error. C.

Which statement about the following declarations is correct? 

import java.lang.annotation. *; import java.util.List; @Target (ElementType.TYPE_USE) public @interface Friend { String

A. None of the declarations compile.

B. Only the declaration of Friend contains a compiler error.

C. Only the declaration of MyFriends contains a compiler error.

D. Both declarations contain compiler errors.

E. None of the above.

import java.lang.annotation. *; import java.util.List; @Target (ElementType.TYPE_USE) public @interface Friend { String value (); String lastName () default null; int age = 10; } class My Friends { } void makeFriends () { var friends = List.of(new @Friend ("Olivia") Object(), new @Friend ("Adeline") String(), new @Friend ("Henry") MyFriends ()); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The code snippet presents a custom Java annotation named Friend and a class MyFriends with a method ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Oracle Questions!