1/14
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What is an annotation in Java?
A special form of metadata that provides data about a program but is not part of the program itself.
What is the purpose of annotations in Java?
To provide information to the compiler or runtime for processing code.
What symbol is used to define an annotation?
The @
symbol.
Name a common built-in annotation.
@Override
What does @Override do?
Indicates that a method is intended to override a method in a superclass.
What does @Deprecated mean?
Marks a method or class as outdated and warns that it should not be used.
What does @SuppressWarnings do?
Instructs the compiler to suppress specific warnings.
What is a meta-annotation?
An annotation that applies to other annotations, like @Retention
and @Target
.
What does @Retention specify?
How long the annotation should be retained (SOURCE, CLASS, or RUNTIME).
What does @Target define?
The kinds of program elements an annotation can be applied to (e.g., METHOD, FIELD, TYPE).
What does @Documented do?
Indicates that the annotation should be included in the generated Javadoc.
What is @Inherited used for?
Indicates that an annotation should be inherited by subclasses.
How do you define a custom annotation?
Using @interface
keyword.
Can annotations have parameters?
Yes, they can define methods that act as elements with default or required values.
Where are annotations commonly used?
In frameworks like Spring, JUnit, and Hibernate for configuration and behavior control.