Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam Certified Platform Developer II All Questions

View all questions & answers for the Certified Platform Developer II exam

Exam Certified Platform Developer II topic 1 question 243 discussion

Actual exam question from Salesforce's Certified Platform Developer II
Question #: 243
Topic #: 1
[All Certified Platform Developer II Questions]

Universal Containers stores user preferences in a Hierarchy Custom Setting, User_Prefs_c, with a Checkbox field, Show_Help_c. Company-level defaults are stored at the organizational level, but may be overridden at the user level. If a user has not overridden preferences, then the defaults should be used.
How should the Show_Help_c preference be retrieved for the current user?

  • A. Boolean show = User_Prefs__c.getValues(UserInfo.getUserId()).Show_Help__c;
  • B. Boolean show = User_Prefs__c.getInstance().Show_Help__c;
  • C. Boolean show = User_Prefs__c.Show_Help__c;
  • D. Boolean show = User_Prefs__c.getValues().Show_Help__c;
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Flamebird
Highly Voted 2 years, 11 months ago
B is correct. You will get null pointer in A if there is not User assigned record. As per description, org defaults are overridden by User assigned settings (there is Profile assignments but they are not mentioned in requirements). Ugly question
upvoted 7 times
...
FriedConsole2000
Most Recent 9 months, 1 week ago
Selected Answer: B
B is correct.
upvoted 1 times
...
stan_malta
1 year ago
Selected Answer: B
"If a user has not overridden preferences, then the defaults should be used." - this makes A infeasible
upvoted 2 times
...
BrucePark
1 year, 3 months ago
Selected Answer: A
A is correct. I've tested it and it's working well.
upvoted 1 times
...
Rajashish
1 year, 8 months ago
The correct answer is B. It is mentioned in question that 'If a user has not overridden preferences, then the defaults should be used'. this can only possible if you use getInstance() method because it if it doesn't found value at user level it retrieves values from Org level. On the other hand, getValues(userId) returns null if no values present for that user.
upvoted 4 times
...
mageshrr
2 years ago
The Correct Answer is B, A is the wrong answer and throwing Null Pointer Exception.
upvoted 2 times
...
OmShantiVeg
2 years, 4 months ago
Correct Ans is A
upvoted 1 times
vm1406
2 years ago
getValues() method is used only with a List Custom Setting
upvoted 2 times
BrucePark
1 year, 3 months ago
No it is also available at Hierarchy.
upvoted 1 times
...
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...