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?

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
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
Get step-by-step solutions from verified subject matter experts
