Question: Assume the following code compiles. Which annotation inserted in the line allows the code to print a non-null value at runtime? A. @Inherited B. @Polymorphism

Assume the following code compiles. Which annotation inserted in the line allows the code to print a non-null value at runtime? 

// INSERT HERE @interface Fast { } int topSpeed () default 10;

A. @Inherited

B. @Polymorphism

C. @Inheritance

D. @Retention

E. @Subclass

F. None of the above.

// INSERT HERE @interface Fast { } int topSpeed () default 10; @Fast class BigCat {} public class Cheetah extends BigCat { public static void main(String... unused) { var a = Cheetah.class.getAnnotation (Fast.class); System.out.print(a); } }

Step by Step Solution

3.46 Rating (162 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The question refers to a custom annotation definition in Java and how it is inherited by subclasses To achieve the goal of printing a nonnull value at ... 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!