Praxis Academy
Home › Platform Developer II › Advanced Developer Fundamentals

Platform Developer II practice questions: Advanced Developer Fundamentals

Advanced Developer Fundamentals is 15% of the Salesforce Certified Platform Developer II exam. It covers multi-currency, localization, Apex managed sharing, security enforcement, custom metadata and dynamic Apex. Try these 12 free questions, then open each answer to see why every option is right or wrong.

01

A multi-currency org has corporate currency USD. A Mexico-based sales manager whose user currency is MXN opens a Lightning web component that lists opportunities from several countries, and wants all amounts shown in MXN. Which query should the Apex controller use?

  1. SELECT Name, Amount FROM Opportunity, then divide by the MXN rate in JavaScript
  2. SELECT Name, FORMAT(Amount) FROM Opportunity
  3. SELECT Name, convertCurrency(Amount) FROM Opportunity
  4. SELECT Name, Amount FROM Opportunity WHERE CurrencyIsoCode = 'MXN'
Show answer

Answer: C

A. SELECT Name, Amount FROM Opportunity, then divide by the MXN rate in JavaScriptManual conversion in the client duplicates platform logic and can use the wrong rate.
B. SELECT Name, FORMAT(Amount) FROM OpportunityFORMAT applies locale formatting to the value in the record's currency; it does not convert to the user's currency.
C. SELECT Name, convertCurrency(Amount) FROM Opportunity ✓Correct. convertCurrency() returns currency fields converted to the running user's currency.
D. SELECT Name, Amount FROM Opportunity WHERE CurrencyIsoCode = 'MXN'This filters to MXN opportunities only instead of converting all amounts.

Why: In multi-currency orgs, convertCurrency() in the SELECT clause converts currency field values into the user's currency.

02

An ISV builds a managed package that must install in both single-currency and multi-currency orgs. One class needs to read the record currency. Which approach avoids compile or install failures in single-currency orgs?

  1. Reference opp.CurrencyIsoCode directly and require multi-currency as a package dependency
  2. Check UserInfo.isMultiCurrencyOrganization() and read the value dynamically with record.get('CurrencyIsoCode')
  3. Use convertCurrency() in a static SOQL query
  4. Store the currency code in a hierarchy custom setting for each user
Show answer

Answer: B

A. Reference opp.CurrencyIsoCode directly and require multi-currency as a package dependencyThis blocks installation in single-currency orgs, which the package must support.
B. Check UserInfo.isMultiCurrencyOrganization() and read the value dynamically with record.get('CurrencyIsoCode') ✓Correct. Dynamic field access avoids a hard compile-time reference to a field that doesn't exist in single-currency orgs.
C. Use convertCurrency() in a static SOQL queryStatic SOQL using multi-currency features creates the same dependency on multi-currency.
D. Store the currency code in a hierarchy custom setting for each userThis duplicates data and does not reflect each record's actual currency.

Why: Packages that support both org types should guard currency logic with UserInfo.isMultiCurrencyOrganization() and use dynamic Apex for CurrencyIsoCode.

03

A Lightning web component used by agents in several countries has a hardcoded button label 'Escalate Case'. The label already exists as a translated custom label named Escalate_Case. How should the component reference it?

  1. Call an Apex method that returns System.Label.Escalate_Case
  2. import ESCALATE from '@salesforce/label/c.Escalate_Case'; and expose it through a property used in the template
  3. Use {!$Label.c.Escalate_Case} directly in the HTML template
  4. Read the label from the lightning/uiRecordApi getRecord adapter
Show answer

Answer: B

A. Call an Apex method that returns System.Label.Escalate_CaseAn Apex round trip is unnecessary; LWC can import labels directly.
B. import ESCALATE from '@salesforce/label/c.Escalate_Case'; and expose it through a property used in the template ✓Correct. Importing from @salesforce/label gives the component the label in the user's language.
C. Use {!$Label.c.Escalate_Case} directly in the HTML templateThat expression syntax belongs to Visualforce and Aura, not to LWC templates.
D. Read the label from the lightning/uiRecordApi getRecord adaptergetRecord loads record data, not custom labels.

Why: LWC imports custom labels with @salesforce/label/c.LabelName; the platform resolves the user's language at runtime.

04

An Apex class builds a plain-text summary for users in many countries and must render a date and a decimal using each running user's locale conventions. Which methods produce locale-aware output? (Choose 2)

  1. Date.format()
  2. String.valueOf(myDate)
  3. myDatetime.formatGmt('yyyy-MM-dd')
  4. Decimal.format()
  5. JSON.serialize(myDate)
Show answer

Answer: A, D

A. Date.format() ✓Correct. Date.format() returns the date as a string using the context user's locale.
B. String.valueOf(myDate)String.valueOf returns a fixed yyyy-MM-dd format regardless of locale.
C. myDatetime.formatGmt('yyyy-MM-dd')formatGmt applies a fixed pattern in GMT and ignores the user's locale and time zone.
D. Decimal.format() ✓Correct. Decimal.format() returns the value using the context user's locale, including separators.
E. JSON.serialize(myDate)JSON serialization uses a fixed ISO format intended for machines, not users.

Why: Methods such as Date.format(), Datetime.format() and Decimal.format() use the context user's locale; valueOf and JSON produce fixed formats.

05

A developer tries to write Apex managed sharing for a custom object, but no share object (Object__Share) is available for it. Which situations explain this? (Choose 2)

  1. The object's org-wide default is Public Read/Write
  2. The object has more than one record type
  3. The object has field history tracking enabled
  4. The object was deployed through a change set
  5. The object is the detail side of a master-detail relationship
Show answer

Answer: A, E

A. The object's org-wide default is Public Read/Write ✓Correct. Share objects are not used when the OWD already grants full access, so none is available.
B. The object has more than one record typeRecord types do not affect whether a share object exists.
C. The object has field history tracking enabledField history tracking is unrelated to record sharing.
D. The object was deployed through a change setThe deployment method does not determine sharing structures.
E. The object is the detail side of a master-detail relationship ✓Correct. Detail records inherit access from their master, so they have no share object of their own.

Why: Custom objects have a share object only when their OWD is Private or Public Read Only and they are not controlled by a parent through master-detail.

06

A with sharing Apex controller returns Employee__c records, including the Salary__c field, to a Lightning web component. Users who lack field-level access to Salary__c can still see it. Which changes enforce field-level security? (Choose 2)

  1. Change the class declaration to inherited sharing
  2. Add WITH USER_MODE to the SOQL query
  3. Pass the results through Security.stripInaccessible(AccessType.READABLE, records)
  4. Mark the method @AuraEnabled(cacheable=true)
  5. Move the query to a separate class declared with sharing
Show answer

Answer: B, C

A. Change the class declaration to inherited sharingSharing keywords control record visibility only; they do not enforce field-level security.
B. Add WITH USER_MODE to the SOQL query ✓Correct. User mode enforces object permissions, field-level security and sharing for the query.
C. Pass the results through Security.stripInaccessible(AccessType.READABLE, records) ✓Correct. stripInaccessible removes fields the user cannot read from the returned records.
D. Mark the method @AuraEnabled(cacheable=true)Caching does not change which fields are returned.
E. Move the query to a separate class declared with sharingThe sharing keyword already applies and still does not enforce FLS.

Why: with sharing enforces record-level access only. Use WITH USER_MODE, AccessLevel.USER_MODE or Security.stripInaccessible to enforce CRUD and FLS.

07

A trigger on Opportunity calls OppRollupHandler, declared with sharing, to total all Opportunity amounts for each Account. When a sales rep edits an opportunity, the Account total excludes opportunities the rep cannot see. What should the developer change?

  1. Move the rollup into a before-insert trigger
  2. Declare the rollup handler without sharing so the query sees all related records
  3. Add WITH USER_MODE to the rollup query
  4. Use System.runAs() with an admin user inside the handler
Show answer

Answer: B

A. Move the rollup into a before-insert triggerTrigger timing does not change which records the query can see.
B. Declare the rollup handler without sharing so the query sees all related records ✓Correct. Triggers run in system context, but a with sharing handler enforces the user's sharing; rollups need without sharing.
C. Add WITH USER_MODE to the rollup queryUser mode enforces the rep's sharing and permissions, making the problem worse.
D. Use System.runAs() with an admin user inside the handlerSystem.runAs is only available in test methods.

Why: Triggers execute in system mode, but the sharing keyword of called classes still applies. Aggregations that need all records belong in without sharing classes.

08

A search page builds this query: String q = 'SELECT Id FROM Product2 WHERE Name LIKE \'%' + userInput + '%\' ORDER BY ' + sortField; where both userInput and sortField come from URL parameters. Which changes protect against SOQL injection? (Choose 2)

  1. Pass userInput as a bind variable, for example with Database.queryWithBinds()
  2. Encode userInput with HTMLENCODE() before building the query
  3. Validate sortField against the field names returned by Schema.SObjectType.Product2.fields.getMap()
  4. Wrap Database.query() in a try/catch block
  5. Run the query in a without sharing class
Show answer

Answer: A, C

A. Pass userInput as a bind variable, for example with Database.queryWithBinds() ✓Correct. Bind variables are treated as data, so user input cannot change the query structure.
B. Encode userInput with HTMLENCODE() before building the queryHTMLENCODE protects HTML output, not SOQL syntax.
C. Validate sortField against the field names returned by Schema.SObjectType.Product2.fields.getMap() ✓Correct. Field names cannot be bound, so they must be checked against an allowlist from the schema.
D. Wrap Database.query() in a try/catch blockCatching errors does not prevent a malicious query from running successfully.
E. Run the query in a without sharing classRemoving sharing increases exposure if injection succeeds.

Why: Prevent SOQL injection with bind variables for values and allowlist validation for identifiers such as field names. String.escapeSingleQuotes is a fallback for string literals.

09

Legacy Apex creates Lead records for web-form submissions and must fail gracefully, with a friendly message, if the running user cannot create Leads. The team cannot yet move the DML to user mode. Which check should run before the insert?

  1. if (!Schema.sObjectType.Lead.isCreateable()) { /* show message */ }
  2. if (!Schema.sObjectType.Lead.isAccessible()) { /* show message */ }
  3. if (UserInfo.getUserType() != 'Standard') { /* show message */ }
  4. if (Limits.getDmlStatements() > 0) { /* show message */ }
Show answer

Answer: A

A. if (!Schema.sObjectType.Lead.isCreateable()) { /* show message */ } ✓Correct. DescribeSObjectResult.isCreateable() reports whether the running user has create permission on the object.
B. if (!Schema.sObjectType.Lead.isAccessible()) { /* show message */ }isAccessible checks read access, not create access.
C. if (UserInfo.getUserType() != 'Standard') { /* show message */ }User type does not reflect object permissions from profiles and permission sets.
D. if (Limits.getDmlStatements() > 0) { /* show message */ }This checks governor limit usage, not permissions.

Why: Schema describe methods (isAccessible, isCreateable, isUpdateable, isDeletable) let Apex check CRUD and FLS manually when user-mode operations are not used.

10

A hierarchy custom setting Discount_Config__c has Max_Discount__c = 10 at the org level and 20 for the 'Sales Manager' profile. No user-level record exists. A Sales Manager runs code that calls Discount_Config__c.getInstance().Max_Discount__c. What value is returned?

  1. 10, because the org default always takes precedence
  2. null, because there is no user-level record
  3. An exception, because getInstance() requires a user Id
  4. 20, from the profile-level record
Show answer

Answer: D

A. 10, because the org default always takes precedenceThe org default is the lowest-priority level in the hierarchy.
B. null, because there is no user-level recordgetInstance() merges values from the hierarchy rather than returning only the user level.
C. An exception, because getInstance() requires a user IdgetInstance() without arguments uses the current user.
D. 20, from the profile-level record ✓Correct. getInstance() returns the most specific value available: user, then profile, then org default.

Why: Hierarchy custom settings resolve values from the most specific level: user, then profile, then organization.

11

A logistics company wants a validation rule on Shipment__c that blocks weights above a limit stored per region in the custom metadata type Weight_Limit__mdt, so that admins can change limits without code. How can the validation rule reference the limit?

  1. $CustomMetadata.Weight_Limit__mdt.North.Max_Kg__c
  2. $Setup.Weight_Limit__mdt.Max_Kg__c
  3. $Label.Weight_Limit__mdt.Max_Kg__c
  4. VLOOKUP($ObjectType.Weight_Limit__mdt.Fields.Max_Kg__c, ...)
Show answer

Answer: A

A. $CustomMetadata.Weight_Limit__mdt.North.Max_Kg__c ✓Correct. Validation rules and formulas can reference custom metadata records through the $CustomMetadata global variable.
B. $Setup.Weight_Limit__mdt.Max_Kg__c$Setup is used for hierarchy custom settings, not custom metadata types.
C. $Label.Weight_Limit__mdt.Max_Kg__c$Label references custom labels, not custom metadata fields.
D. VLOOKUP($ObjectType.Weight_Limit__mdt.Fields.Max_Kg__c, ...)VLOOKUP works against custom objects, not custom metadata types.

Why: Formulas, validation rules and default values can read custom metadata with $CustomMetadata.Type__mdt.RecordName.Field__c.

12

A generic logging service receives SObject records from many different queries and must record only the fields that were actually queried or set on each record, without knowing the object in advance. Which method should it use?

  1. record.getPopulatedFieldsAsMap()
  2. record.getSObjectType().getDescribe().fields.getMap()
  3. JSON.serialize(record.getSObjectType())
  4. record.clone(false, true).keySet()
Show answer

Answer: A

A. record.getPopulatedFieldsAsMap() ✓Correct. getPopulatedFieldsAsMap() returns a map of the fields populated in memory on that record instance, keyed by field name.
B. record.getSObjectType().getDescribe().fields.getMap()This returns all fields defined on the object, not just those populated on the record.
C. JSON.serialize(record.getSObjectType())Serializing the type token does not include record field values.
D. record.clone(false, true).keySet()clone returns an SObject, which does not provide keySet().

Why: SObject.getPopulatedFieldsAsMap() lists only the fields present on a record instance, avoiding errors from reading fields that were not queried.

Find out if you're ready to pass

Take the free Platform Developer II diagnostic: 20 questions, no account needed. Then unlock all 300 questions, full practice exams and the study guide.

Start the free diagnosticSee plans

Other sections of this exam