Exam 1z0-819 All QuestionsBrowse all questions from this exam
Question 57

Given:

What is the correct definition of the JsonField annotation that makes the Point class compile?

    Correct Answer: D

    The correct definition of the JsonField annotation that makes the Point class compile is the one where the @Target is ElementType.FIELD. This is because the annotation is applied to fields in the Point class. Additionally, the annotation should have the retention policy and the name attribute should provide a default value, which makes it optional to specify the name attribute when using the annotation. Therefore, the correct definition includes @Target(ElementType.FIELD), @Retention(RetentionPolicy.RUNTIME), and String name() default "";.

Discussion
d7bb0b2Option: D

D is correct, cause name is default value, is not required when use an anotaccion, and TYPE is FIELD not method. C is incorrect cause name is mandatory if not has a default value

RoxyFoxyOption: D

String name() is not mandatory for all instance variables, because it has a default value so C is not correct. type() is specified for all variables because has no default value.

RoxyFoxy

ElementType.FIELD - applies to instance and static variables, and enum values. In this example _name, x and y are all instance variables, and all have type=..., so type() mandatory.

OmnisumemOption: C

Tested: C!

Ashan_Ozlov

But C doesn't compile, I tested and D is correct

[Removed]Option: D

C is incorrect as name needs a default value. D is correct because of the ElementType.FIELD being used correctly. B is incorrect because ElementType.TYPE can only be used for: Class, interface (including annotation type), or enum declaration

StavokOption: C

C is correct This definition includes the required elements name and type, with name having a default value of an empty string. The Type enum is also defined with the required values INT, STRING, and BOOLEAN. The annotation does not need to specify a target or retention policy to compile.

tmuralimanoharOption: D

Answer: D

NayoumiOption: D

D is the correct answer

Ankit1010Option: D

Correct answer is D. Because of, @Target(ElementType.FIELD) String name() default "";

ObaltOption: D

The correct answer is D