Exam AD0-E103 All QuestionsBrowse all questions from this exam
Question 27

A developer is creating a custom method. This method must return a String property y from child x. the method must use only Sling APIs.

How should the developer retrieve property y of node x, and node x may or may NOT exist?

A.

B.

C.

D.

    Correct Answer:

    To retrieve property 'y' of node 'x' using Sling APIs, and considering the possibility that node 'x' may or may not exist, the correct approach involves checking for null values to avoid NullPointerException (NPE). The correct approach is shown in option B. Option B ensures that null checks are properly handled before accessing the properties, which avoids NPEs. The ValueMap is correctly retrieved and used to get the property 'y'. Hence, the correct answer is B.

Discussion
chunpin

Answer: B -------------------------------------------------------------- A: will cause nullpointer, hence wrong C: getProperties return PropertyIterator , hence wrong D: node does not have method getValueMap(), hence wrong B: should have ValueMap map = x.getValueMap();

kasyap1125

Option B value map declaration is wrong. it is having ValueMap<String> which is wrong. So, I guess it is A.

pkg82

A may cause NPE. so correct answer is B

heenamadan

Should be B