About Question enthuware.ocpjp.v11.2.3375 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
cjgiron
Posts: 14
Joined: Fri Sep 09, 2022 5:03 pm
Contact:

About Question enthuware.ocpjp.v11.2.3375 :

Post by cjgiron »

Where can I find the explanation for this question? Is there a resource that defines which annotations are defined with @Retention and explains why they are defined with that RetentionPolicy?

admin
Site Admin
Posts: 10046
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v11.2.3375 :

Post by admin »

1. All annotations have a Retention policy (it is one of SOURCE, CLASS, and RUNTIME).
2. No, there is no official document that lists all the annotations with their runtime policy. But if you remember this information for the annotations included in this question, you will be ready for the exam.
3. Setting a retention policy is a design decision depending on the purpose of the annotation i.e. what the annotation developer wants achieve with that annotation. For example, the @Override annotation is meant to check at compile time whether the method does really override a superclass method so that the developer can be warned of a coding mistake. This information has no use at runtime. So, the retention policy for this annotation is SOURCE.
Similarly, you can take any annotation, see what is its purpose and then decide whether you need that information at run time or not.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 47 guests