2 packs: 15% off with code BUY2. 3 or more: 20% off with code BUY3.

Free Salesforce Platform Developer Practice Questions

104 free Salesforce Platform Developer practice questions from the CertStash pack of 439, each with the correct answer and a full explanation. The rule is the same for every exam: ten free on the product page, 104 free here, all 439 in the pack, and each step includes the one before it.

Question 1

Which statement results in an Apex compiler error?

  1. Map<Id,Leas> lmap = new Map<Id,Lead>([Select ID from Lead Limit 8]);
  2. Date d1 = Date.Today(), d2 = Date.ValueOf('2018-01-01');
  3. Integer a=5, b=6, c, d = 7;
  4. List<string> s = List<string>{'a','b','c');
Show answer and explanation

Correct answer: D. List<string> s = List<string>{'a','b','c');

A list literal has to be constructed with the new keyword and closed with the same kind of bracket it opened with. Option D writes List<string> s = List<string>{'a','b','c'); which omits new and closes a brace with a parenthesis, so the compiler rejects it before the code ever runs. The other three lines are legal Apex: multiple variables of one type can be declared and initialised in a single statement, and a declared variable may be left unassigned.

Why the other options are wrong

  • A. This compiles. Leas is read as an unresolved type name only if no such type exists, and the exam prints this line as Map<Id, Lead>, so the statement is a valid map construction from a SOQL result.
  • B. Declaring two Date variables in one statement and initialising them with Date.today() and Date.valueOf() is valid Apex.
  • C. Apex allows several variables of the same type in one declaration, and leaving c uninitialised is legal because it simply defaults to null.

Question 2

What are two benefits of the Lightning Component framework? (Choose two.)

  1. It simplifies complexity when building pages, but not applications.
  2. It provides an event-driven architecture for better decoupling between components.
  3. It promotes faster development using out-of-box components that are suitable for desktop and mobile devices.
  4. It allows faster PDF generation with Lightning components.
Show answer and explanation

Correct answer: B, C. It provides an event-driven architecture for better decoupling between components; It promotes faster development using out-of-box components that are suitable for desktop and mobile devices.

The framework is built on an event driven model: components fire and handle events rather than calling into each other directly, which keeps them loosely coupled and independently reusable. It also ships a large set of out-of-box base components that already render correctly on desktop and mobile, so developers assemble screens from tested building blocks instead of writing markup from scratch. Those two properties are the standard stated benefits.

Why the other options are wrong

  • A. The framework reduces complexity for applications as well as pages, so the qualifier makes this false.
  • D. PDF generation is a Visualforce capability through renderAs="pdf". Lightning components do not provide it, let alone faster.

Question 3

A method is passed a list of generic sObjects as a parameter. What should the developer do to determine which object type (Account, Lead, or Contact, for example) to cast each sObject?

  1. Use the first three characters of the sObject ID to determine the sObject type.
  2. Use the getSObjectType method on each generic sObject to retrieve the sObject token.
  3. Use the getSObjectName method on the sObject class to get the sObject name.
  4. Use a try-catch construct to cast the sObject into one of the three sObject types.
Show answer and explanation

Correct answer: B. Use the getSObjectType method on each generic sObject to retrieve the sObject token.

Every sObject instance exposes getSObjectType(), which returns the Schema.SObjectType token for that record's object. Calling it on each generic sObject tells the code exactly what it is holding, and the token can then be compared against Account.SObjectType, Lead.SObjectType and so on, or fed to newSObject() to cast. It is the supported, describe-driven way to branch on object type.

Why the other options are wrong

  • A. Key prefixes do identify an object, but reading the first three characters of an ID means hardcoding prefixes or querying EntityDefinition to map them. It is indirect and brittle next to a single method call.
  • C. There is no getSObjectName method on the sObject class. The describe result exposes getName(), reached through getSObjectType().getDescribe().
  • D. Casting inside a try-catch treats a type check as an exception handler. It works only by failing repeatedly and is not how type is determined.

Question 4

When viewing a Quote, the sales representative wants to easily see how many discounted items are included in the Quote Line Items. What should a developer do to meet this requirement?

  1. Create a trigger on the Quote object that queries the Quantity field on discounted Quote Line Items.
  2. Create a Workflow Rule on the Quote Line Item object that updates a field on the parent Quote when the item is discounted.
  3. Create a roll-up summary field on the Quote object that performs a SUM on the quote Line Item Quantity field, filtered for only discounted Quote Line Items.
  4. Create a formula field on the Quote object that performs a SUM on the Quote Line Item Quantity field, filtered for only discounted Quote Line Items.
Show answer and explanation

Correct answer: C. Create a roll-up summary field on the Quote object that performs a SUM on the quote Line Item Quantity field, filtered for only discounted Quote Line Items.

Quote Line Item is the detail side of a master-detail relationship to Quote, which is exactly the condition a roll-up summary field requires. The roll-up can aggregate the Quantity field and apply a filter so only discounted line items are counted, and the total is maintained by the platform on the parent Quote with no code. That gives the sales representative the figure directly on the Quote record.

Why the other options are wrong

  • A. A trigger is code where a declarative roll-up already does the job, and querying the field does not by itself surface the number on the Quote.
  • B. A Workflow Rule field update cannot aggregate values from many child records into a parent total.
  • D. Formula fields evaluate on a single record and cannot sum values across child records. Cross-object formulas only reach upward to a parent.

Question 5

A Developer wants to get access to the standard price book in the org while writing a test class that covers an OpportunityLineItem trigger. Which method allows access to the price book?

  1. Use Test.getStandardPricebookId() to get the standard price book ID.
  2. Use @IsTest(SeeAllData=true) and delete the existing standard price book.
  3. Use Test.loadData() and a Static Resource to load a standard price book.
  4. Use @TestVisible to allow the test method to see the standard price book.
Show answer and explanation

Correct answer: A. Use Test.getStandardPricebookId() to get the standard price book ID.

Test.getStandardPricebookId() returns the ID of the org's standard price book from inside a test, which is the supported way to get at it when the test cannot see organisation data. A new PricebookEntry can then be created against that ID so an OpportunityLineItem can be inserted and the trigger exercised.

Why the other options are wrong

  • B. SeeAllData=true couples the test to org data, and deleting the standard price book is destructive and not permitted.
  • C. Test.loadData() loads records from a static resource. The standard price book already exists and cannot be created this way.
  • D. @TestVisible exposes private members of Apex classes to tests. It has nothing to do with record visibility.

Question 6

Which two Apex data types can be used to reference a Salesforce record ID dynamically? (Choose two.)

  1. ENUM
  2. sObject
  3. External ID
  4. String
Show answer and explanation

Correct answer: B, D. sObject; String

A record ID can be held dynamically in a String, since an ID is textual and Apex converts between String and Id freely. It can also be reached through an sObject, because any sObject instance carries its Id field and can be addressed generically with get('Id'). Those are the two data types that work without knowing the concrete object at compile time.

Why the other options are wrong

  • A. An ENUM is a fixed set of named constants defined at compile time, so it cannot hold an arbitrary record ID.
  • C. External ID is a field attribute, not an Apex data type. The underlying field may be Text, Number or Email, none of which is guaranteed to hold a record ID.

Question 7

Where can a developer identify the time taken by each process in a transaction using Developer Console log inspector?

  1. Performance Tree tab under Stack Tree panel
  2. Execution Tree tab under Stack Tree panel
  3. Timeline tab under Execution Overview panel
  4. Save Order tab under Execution Overview panel
Show answer and explanation

Correct answer: C. Timeline tab under Execution Overview panel

The Timeline tab in the Execution Overview panel plots the transaction against elapsed time and shows how long each category of work took, so it is where a developer sees the time consumed by each process. The other panels describe what ran and in what order rather than how long it took.

Why the other options are wrong

  • A. There is no Performance Tree tab. The Stack Tree panel holds Execution Tree and Performance Tree views of call nesting, not per-process timing.
  • B. The Execution Tree shows the hierarchy of what executed, not the duration of each step.
  • D. Save Order shows the order of save operations for the transaction, not timing.

Question 8

A developer needs to test an Invoicing system integration. After reviewing the number of transactions required for the test, the developer estimates that the test data will total about 2 GB of data storage. Production data is not required for the integration testing. Which two environments meet the requirements for testing? (Choose two.)

  1. Developer Sandbox
  2. Full Sandbox
  3. Developer Edition
  4. Partial Sandbox
  5. Developer Pro Sandbox
Show answer and explanation

Correct answer: B, D. Full Sandbox; Partial Sandbox

The test needs roughly 2 GB of data storage but no production data. Full and Partial Copy sandboxes are the two environments whose storage allowance is large enough: Full provides the same storage as production, and Partial Copy provides 5 GB of data storage. Both comfortably hold 2 GB, and the fact that they can copy production data does not disqualify them because copying is optional.

Why the other options are wrong

  • A. A Developer Sandbox is capped at 200 MB of data storage, far short of 2 GB.
  • C. A Developer Edition org is not a sandbox and offers only a few hundred megabytes.
  • E. A Developer Pro Sandbox is capped at 1 GB, still short of the 2 GB required.

Question 9

Which three steps allow a custom SVG to be included in a Lightning web component? (Choose three.)

  1. Upload the SVG as a static resource.
  2. Reference the getter in the HTML template.
  3. Import the SVG as a content asset file.
  4. Import the static resource and provide a getter for it in JavaScript.
  5. Reference the import in the HTML template.
Show answer and explanation

Correct answer: A, B, D. Upload the SVG as a static resource; Reference the getter in the HTML template; Import the static resource and provide a getter for it in JavaScript.

An SVG is delivered to a component in three steps: upload it as a static resource, import that resource in the JavaScript file and expose it through a getter, then reference the getter from the HTML template. The getter is needed because a template can only bind to properties of the component, not to an imported module directly.

Why the other options are wrong

  • C. Content asset files are an alternative delivery mechanism, but they are not part of the static resource route these steps describe.
  • E. The template cannot reference the import itself. It binds to the getter, which is why the getter step exists.

Question 10

Which set of roll-up types are available when creating a roll-up summary field?

  1. COUNT, SUM, MIN, MAX
  2. AVERAGE, SUM, MIN, MAX
  3. SUM, MIN, MAX
  4. AVRAGE, COUNT, SUM, MIN, MAX
Show answer and explanation

Correct answer: A. COUNT, SUM, MIN, MAX

A roll-up summary field aggregates child records across a master-detail relationship using one of four functions: COUNT, SUM, MIN and MAX. There is no averaging function, and an average has to be derived with a formula that divides a SUM roll-up by a COUNT roll-up.

Why the other options are wrong

  • B. AVERAGE is not an available roll-up type, and omitting COUNT leaves out one that is.
  • C. COUNT is missing. It is one of the four supported types.
  • D. AVERAGE is not offered regardless of spelling.

What people say about the full Platform Developer pack 4.6 from 16

Thanks for your PDI exam dumps. I took my exam today and passed. The questions from Cert Stash are 100% valid. I recommend it to all you guys.
OpheliaPlatform Developer
Passed my PDI exam. I can say the PDI exam questions are 100% valid. Thanks, Cert Stash.
TrudaPlatform Developer
Almost all the PDI questions are from your dumps.
BurkePlatform Developer

Question 11

A developer is asked to create a custom Visualforce page that will be used as a dashboard component. Which three are valid controller options for this page? (Choose three.)

  1. Use a standard controller.
  2. Use a standard controller with extensions.
  3. Use a custom controller with extensions.
  4. Do not specify a controller.
  5. Use a custom controller.
Show answer and explanation

Correct answer: C, D, E. Use a custom controller with extensions; Do not specify a controller; Use a custom controller.

A Visualforce page used as a dashboard component cannot use a standard controller, because a dashboard has no single record context. That leaves specifying no controller at all, using a custom controller, or using a custom controller with extensions. All three are valid for a dashboard component.

Why the other options are wrong

  • A. A standard controller requires a record ID, which a dashboard does not supply, so such pages cannot be added to a dashboard.
  • B. Adding an extension does not remove the standard controller, so the page is still ineligible.

Question 12

A developer identifies the following triggers on the Expense__c object: deteleExpense, applyDefaultsToExpense, validateExpenseUpdate; The triggers process before delete, before insert, and before update events respectively. Which two techniques should the developer implement to ensure trigger best practices are followed? (Choose two.)

  1. Unify the before insert and before update triggers and use Process Builder for the delete action.
  2. Create helper classes to execute the appropriate logic when a record is saved.
  3. Maintain all three triggers on the Expense__c object, but move the Apex logic out of the trigger definition.
  4. Unify all three triggers in a single trigger on the Expense__c object that includes all events.
Show answer and explanation

Correct answer: B, D. Create helper classes to execute the appropriate logic when a record is saved; Unify all three triggers in a single trigger on the Expense__c object that includes all events.

Two practices apply. All three events belong in one trigger per object, because Salesforce does not guarantee the execution order of multiple triggers on the same object, and consolidating them puts the sequence under the developer's control. The logic itself then moves into helper classes, keeping the trigger a thin dispatcher that is easy to test and reuse.

Why the other options are wrong

  • A. Splitting the delete logic into Process Builder scatters the behaviour across two tools, and Process Builder cannot act on delete.
  • C. Keeping three separate triggers leaves the ordering problem in place. Moving the logic out helps, but the trigger count is the issue being tested.

Question 13

Which three options allow a developer to use custom styling in a Visualforce page? (Choose three.)

  1. <apex:stylesheet> tag
  2. Inline CSS
  3. <apex:style>tag
  4. <apex:stylesheets>tag
  5. A static resource
Show answer and explanation

Correct answer: A, B, E. <apex:stylesheet> tag; Inline CSS; A static resource

Three routes give custom styling. The <apex:stylesheet> tag links a stylesheet into the page, inline CSS in a style block or a style attribute applies rules directly, and a static resource can hold a CSS file that the page references. All three are supported.

Why the other options are wrong

  • C. There is no <apex:style> tag in Visualforce.
  • D. The tag is singular, <apex:stylesheet>. There is no <apex:stylesheets> tag.

Question 14

The Job_Application__c custom object has a field that is a Master-Detail relationship to the Contact object, where the Contact object is the Master. As part of a feature implementation, a developer needs to retrieve a list containing all Contact records where the related Account Industry is `˜Technology' while also retrieving the contact's Job_Application__c records. Based on the object's relationships, what is the most efficient statement to retrieve the list of contacts?

  1. [SELECT Id, (SELECT Id FROM Job_Applications_r) FROM Contact WHERE Account.Industry = 'Technology'];
  2. [SELECT Id, (SELECT Id FROM Job_Applications_r) FROM Contact WHERE Accounts.Industry = 'Technology'];
  3. [SELECT Id, (SELECT Id FROM Job_Applications_c) FROM Contact WHERE Accounts.Industry = 'Technology'];
  4. [SELECT Id, (SELECT Id FROM Job_Application_c) FROM Contact WHERE Account.Industry = 'Technology'];
Show answer and explanation

Correct answer: A. [SELECT Id, (SELECT Id FROM Job_Applications_r) FROM Contact WHERE Account.Industry = 'Technology'];

Two relationship forms are needed. Job_Application__c is the child, so the subquery uses the child relationship name with the __r suffix. Account is the parent of Contact, so the filter walks up with the singular relationship name Account followed by the field. Combining both retrieves the contacts and their job applications in one query.

Why the other options are wrong

  • B. The parent relationship name is Account, not Accounts. Parent traversal is singular.
  • C. The subquery uses __c, which is the object suffix. A child relationship in a subquery takes __r, and the parent name is wrong as well.
  • D. The subquery again uses the object name rather than the child relationship name, so it does not resolve.

Question 15

How can a developer get all of the available record types for the current user on the Case object?

  1. Use DescribeSObjectResult of the Case object.
  2. Use SOQL to get all Cases.
  3. Use DescribeFieldResult of the Case.RecordType field.
  4. Use Case.getRecordTypes().
Show answer and explanation

Correct answer: A. Use DescribeSObjectResult of the Case object.

Record type information hangs off the object describe. Calling getDescribe() on the Case sObject type returns a DescribeSObjectResult whose getRecordTypeInfos() lists every record type, and each entry reports whether it is available to the running user. That is how available record types are determined in Apex.

Why the other options are wrong

  • B. Querying Case records returns data, not the set of record types defined on the object.
  • C. Describing the RecordTypeId field gives field metadata. Record type availability comes from the object describe.
  • D. There is no getRecordTypes() method on the Case class.

Question 16

Which three options can be accomplished with formula fields? (Choose three.)

  1. Generate a link using the HYPERLINK function to a specific record.
  2. Display the previous value for a field using the PRIORVALUE function.
  3. Determine if a datetime field value has passed using the NOW function.
  4. Return and display a field value from another object using the VLOOKUP function.
  5. Determine which of three different images to display using the IF function.
Show answer and explanation

Correct answer: A, C, E. Generate a link using the HYPERLINK function to a specific record; Determine if a datetime field value has passed using the NOW function; Determine which of three different images to display using the IF function.

Formula fields support the HYPERLINK function to render a link to a record, comparisons against NOW() to test whether a datetime has passed, and IF logic combined with IMAGE to choose between different images. All three are standard formula capabilities.

Why the other options are wrong

  • B. PRIORVALUE is available in workflow rules, validation rules and processes, where a prior value exists. A formula field is evaluated on the current record and cannot use it.
  • D. There is no VLOOKUP function in formula fields. It exists only in validation rules, and cross-object references reach a parent rather than performing a lookup.

Question 17

A developer must modify the following code snippet to prevent the number of SOQL queries issued from exceeding the platform governor limit. The above method might be called during a trigger execution via a Lightning component. Which technique should be implemented to avoid reaching the governor limit?

  1. Refactor the code above to perform the SOQL query only if the Set of opportunityIds contains less 100 Ids.
  2. Use the System.Limits.getLimitQueries() method to ensure the number of queries is less than 100.
  3. Refactor the code above to perform only one SOQL query, filtering by the Set of opportunityIds.
  4. Use the System.Limits.getQueries() method to ensure the number of queries is less than 100.
Show answer and explanation

Correct answer: C. Refactor the code above to perform only one SOQL query, filtering by the Set of opportunityIds.

The fix is to stop querying inside the loop. Building a Set of the Opportunity IDs first and then running one query filtered with an IN clause against that set retrieves everything needed in a single SOQL call, so the query count stays at one no matter how many records are processed.

Why the other options are wrong

  • A. Capping the number of IDs limits the damage but still issues one query per record and silently skips work above the threshold.
  • B. getLimitQueries() returns the ceiling, not the current usage, so this comparison does not do what it claims.
  • D. Checking the running count only detects the problem. It does not reduce the number of queries, and the code would still fail on larger volumes.

Question 18

The Review_c object has a lookup relationship up to the Job_Application_c object. The Job_Application_c object has a master-detail relationship up to the Position_c object. The relationship field names are based on the auto-populated defaults. What is the recommended way to display field data from the related Position_c record on a Visualforce page for a single Review_c record?

  1. Use the Standard Controller for Review_c and cross-object Formula Fields on the Position_c object to display Position_c data.
  2. Use the Standard Controller for Job_Application_c and a Controller Extension to query for Position_c data.
  3. Use the Standard Controller for Job_Application_c and cross-object Formula Fields on the Review_c object to display Position_c data.
  4. Use the Standard Controller for Review_c and expression syntax in the Page to display related Position_c data through the Job_Application_c object.
Show answer and explanation

Correct answer: D. Use the Standard Controller for Review_c and expression syntax in the Page to display related Position_c data through the Job_Application_c object.

With the Standard Controller for Review__c the page already has the record in context, and Visualforce expression syntax can walk the relationship fields to reach the Position. Because Review__c looks up to Job_Application__c, which in turn relates to Position__c, an expression that chains through the relationship names displays the Position data with no query and no extra fields.

Why the other options are wrong

  • A. This adds formula fields on Position__c, which is the wrong object. The formula would have to be on Review__c, and creating fields is unnecessary when the page can traverse directly.
  • B. The page is for a single Review record, so the controller must be Review__c. Job_Application__c has no reference back to a specific Review.
  • C. The controller is on the wrong object again, and creating formula fields duplicates data the page can already reach.

Question 19

What is the order of operations when a record is saved in Salesforce?

  1. workflow, process flows, triggers, commit
  2. process flows, triggers, workflow, commit
  3. triggers, workflow, process flows, commit
  4. workflow, triggers, process flows, commit
Show answer and explanation

Correct answer: C. triggers, workflow, process flows, commit

On save the platform runs the Apex triggers first, then evaluates workflow rules, then runs processes and flows that are configured to run after the record is saved, and finally commits the transaction to the database. That is the sequence among the four items listed.

Why the other options are wrong

  • A. Workflow does not run before triggers. Before triggers execute first.
  • B. Processes run after triggers and after workflow, not first.
  • D. Workflow runs after the triggers, not between them and the processes.

Question 20

A developer executes the following query in Apex to retrieve a list of contacts for each account: List<account> accounts = [Select ID, Name, (Select ID, Name from Contacts) from Account] ; Which two exceptions may occur when it executes? (Choose two.)

  1. CPU limit exception due to the complexity of the query.
  2. SOQL query row limit exception due to the number of contacts.
  3. SOQL query limit exception due to the number of contacts.
  4. SOQL query row limit exception due to the number of accounts.
Show answer and explanation

Correct answer: B, D. SOQL query row limit exception due to the number of contacts; SOQL query row limit exception due to the number of accounts.

A query that returns parents with a child subquery counts both levels against the 50,000 record limit for the transaction. Too many accounts will breach it, and so will too many contacts returned across the subqueries, so a row limit exception can arise from either side. Both are query row limits rather than query count limits, because this is a single statement.

Why the other options are wrong

  • A. There is a CPU time limit, but it is not raised by the shape of the query. Retrieving rows is not what consumes CPU here.
  • C. The number of contacts affects rows returned, not the count of queries issued. The statement counts as one query, or two including the subquery, nowhere near the 100 limit.

Question 21

In a single record, a user selects multiple values from a multi-select picklist. How are the selected values represented in Apex?

  1. As a List<String> with each value as an element in the list
  2. As a String with each value separated by a comma
  3. As a String with each value separated by a semicolon
  4. As a Set<String> with each value as an element in the set
Show answer and explanation

Correct answer: C. As a String with each value separated by a semicolon

A multi-select picklist stores its selected values in a single text field, with the individual values separated by semicolons. In Apex the field therefore reads as one String, and code that needs the values as a collection splits it on the semicolon.

Why the other options are wrong

  • A. Apex does not hand back a List<String>. The developer has to produce one by splitting the stored string.
  • B. The separator is a semicolon, not a comma. A comma would be ambiguous because values may contain commas.
  • D. There is no automatic Set<String> representation, and a set would also discard the stored order.

Question 22

Which tag should a developer include when styling from external CSS is required in a Visualforce page?

  1. apex:includeStyles
  2. apex:includeScript
  3. apex:require
  4. apex:stylesheet
Show answer and explanation

Correct answer: D. apex:stylesheet

The <apex:stylesheet> tag adds a link to an external CSS file in the generated page, which is how a Visualforce page pulls in styling held in a static resource or another external location.

Why the other options are wrong

  • A. There is no apex:includeStyles tag.
  • B. apex:includeScript adds a JavaScript file, not a stylesheet.
  • C. apex:require does not exist. The Lightning tag ltng:require is a different framework.

Question 23

Using the Schema Builder, a developer tries to change the API name of a field that is referenced in an Apex test class. What is the end result?

  1. The API name is not changed and there are no other impacts.
  2. The API name of the field and the reference in the test class is changed.
  3. The API name of the field is changed, and a warning is issued to update the class.
  4. The API name of the field and the reference in the test class is updated.
Show answer and explanation

Correct answer: A. The API name is not changed and there are no other impacts.

Salesforce refuses to rename a field whose API name is referenced in Apex. The save is rejected, so the field keeps its original API name and nothing else in the org changes. Apex references are hard dependencies and the platform protects them rather than letting code break.

Why the other options are wrong

  • B. The platform does not rewrite Apex source when metadata changes, and in this case the rename does not happen at all.
  • C. There is no warn-and-proceed behaviour. The change is blocked outright.
  • D. Neither the field nor the class is updated, because the rename fails.

Question 24

A platform developer at Universal Containers needs to create a custom button for the Account object that, when clicked, will perform a series of calculations and redirect the user to a custom Visualforce page. Which three attributes need to be defined with values in the <apex:page> tag to accomplish this? (Choose three.)

  1. action
  2. renderAs
  3. standardController
  4. readOnly
  5. extensions
Show answer and explanation

Correct answer: A, C, E. action; standardController; extensions

The button targets an Account, so the page needs standardController="Account" to bind to the record. The calculations live in Apex, which is attached with extensions. And because the work has to happen when the page loads rather than on a user click, the action attribute names the method that runs on page load and returns the redirect. Those three attributes deliver the behaviour.

Why the other options are wrong

  • B. renderAs converts the page output to a format such as PDF. Nothing here asks for that.
  • D. readOnly relaxes query row limits for read-only pages. It is unrelated to running calculations and redirecting.

Question 25

A developer declared a class as follows. Which invocation of a class method will obey the organization-wide defaults and sharing settings for the running user in the Salesforce organization?

  1. An Apex trigger that invokes a helper method in this class
  2. A developer using the Developer Console that invokes a method in this class from the execute anonymous window
  3. A Visualforce page with an Apex controller that invokes a method in this class
  4. A user on an external system that has an API call into Salesforce that invokes a method in this class
Show answer and explanation

Correct answer: B. A developer using the Developer Console that invokes a method in this class from the execute anonymous window

Anonymous Apex is the exception to the rule that Apex runs in system context. Code executed from the Developer Console execute anonymous window runs as the logged in user, so organisation-wide defaults and sharing settings for that user are applied.

Why the other options are wrong

  • A. A trigger runs in system context, so sharing is not enforced unless the class is declared with sharing.
  • C. A Visualforce controller runs in system context by default, which is why with sharing exists as an explicit opt-in.
  • D. An API call runs the Apex in system context in the same way. The caller's session determines the user, not whether sharing is enforced.

25 questions in. Want the rest? The first half of the pack, free by email · The full pack

Question 26

Which control statement should a developer use to ensure that a loop body executes at least once?

  1. for (init_stmt; exit_condition; increment_stmt) {"¦}
  2. do {"¦} while (condition)
  3. while (condition) {"¦}
  4. for (variable : list_or_set) {"¦}
Show answer and explanation

Correct answer: B. do {"¦} while (condition)

A do-while loop evaluates its condition after the body has run, so the body always executes at least once no matter what the condition says. Every other loop form tests first and may not run at all.

Why the other options are wrong

  • A. A traditional for loop checks the exit condition before the first iteration, so the body can be skipped entirely.
  • C. A while loop tests the condition up front and runs zero times if it is already false.
  • D. An enhanced for loop over an empty collection performs no iterations.

Question 27

If Apex code executes inside the execute() method of an Apex class when implementing the Batchable interface, which two statements are true regarding governor limits? (Choose two.)

  1. The Apex governor limits are reset for each iteration of the execute() method.
  2. The Apex governor limits cannot be exceeded due to the asynchronous nature of the transaction.
  3. The Apex governor limits might be higher due to the asynchronous nature of the transaction.
  4. The Apex governor limits are relaxed while calling the constructor of the Apex class.
Show answer and explanation

Correct answer: A, C. The Apex governor limits are reset for each iteration of the execute() method; The Apex governor limits might be higher due to the asynchronous nature of the transaction.

Batch Apex splits the work into chunks and calls execute() once per chunk, and each of those calls gets a fresh set of governor limits. Because the code runs asynchronously, some limits are also higher than they would be in a synchronous transaction, for example the heap size and the total number of SOQL query rows.

Why the other options are wrong

  • B. Limits still apply and can absolutely be exceeded. Batch Apex raises and resets them, it does not remove them.
  • D. The constructor runs under normal limits. Nothing is relaxed for it.

Question 28

What will be the output in the debug log in the event of a QueryException during a call to the aQuery method in the following example?

  1. Querying Accounts. Query Exception.
  2. Querying Accounts. Custom Exception.
  3. Querying Accounts. Custom Exception. Done.
  4. Querying Accounts. Query Exception. Done.
Show answer and explanation

Correct answer: D. Querying Accounts. Query Exception. Done.

Catch blocks are evaluated in the order written and the first one whose type matches handles the exception. A QueryException is caught by the QueryException block, so that message is logged rather than the custom one, and the finally block runs afterwards regardless. The output is the initial message, the query exception message, then Done.

Why the other options are wrong

  • A. The finally block always executes, so Done is logged as well.
  • B. The custom exception block does not match a QueryException, so its message is never logged.
  • C. Both the wrong catch block and the missing query exception message make this incorrect.

Question 29

A developer needs to save a List of existing Account records named myAccounts to the database, but the records do not contain Salesforce Id values. Only the value of a custom text field configured as an External ID with an API name of Foreign_Key__c is known. Which two statements enable the developer to save the records to the database without an Id? (Choose two.)

  1. Upsert myAccounts Foreign_Key__c;
  2. Upsert myAccounts(Foreign_Key__c);
  3. Database.upsert (myAccounts, Foreign_Key__c);
  4. Database.upsert(myAccounts).Foreign_Key__c;
Show answer and explanation

Correct answer: A, C. Upsert myAccounts Foreign_Key__c;; Database.upsert (myAccounts, Foreign_Key__c);

Upsert can match on an External ID field instead of the record ID, and there are two ways to write it. The DML statement takes the field token after the list, and the Database.upsert method takes the field token as its second argument. Both save the records by matching on Foreign_Key__c.

Why the other options are wrong

  • B. The External ID field is not passed in parentheses after the list. That is not valid upsert syntax.
  • D. Database.upsert returns save results. A field cannot be appended to the call with dot notation.

Question 30

Given: Map<ID, Account> accountMap = new Map>ID, Account> ([SELECT Id, Name FROM Account]); What are three valid Apex loop structures for iterating through items in the collection? (Choose three.)

  1. for (ID accountID : accountMap.keySet()) {"¦}
  2. for (Account accountRecord : accountMap.values()) {"¦}
  3. for (Integer i=0; I < accountMap.size(); i++) {"¦}
  4. for (ID accountID : accountMap) {"¦}
  5. for (Account accountRecord : accountMap.keySet()) {"¦}
Show answer and explanation

Correct answer: A, B, C. for (ID accountID : accountMap.keySet()) {"¦}; for (Account accountRecord : accountMap.values()) {"¦}; for (Integer i=0; I < accountMap.size(); i++) {"¦}

A Map is not itself iterable, so a loop has to go through one of its collection views or use an index. keySet() returns a Set<ID> that can be iterated with an ID variable, values() returns a List<Account> that can be iterated with an Account variable, and a counted loop bounded by size() is syntactically valid Apex. Those are the three working structures.

Why the other options are wrong

  • D. A Map cannot be placed directly in an enhanced for loop. The code has to iterate keySet() or values().
  • E. keySet() yields IDs, not Account records, so declaring the loop variable as Account is a type mismatch and will not compile.

Question 31

Which aspect of Apex programming is limited due to multitenancy?

  1. The number of methods in an Apex class
  2. The number of records returned from database queries
  3. The number of active Apex classes
  4. The number of records processed in a loop
Show answer and explanation

Correct answer: B. The number of records returned from database queries

Because many customers share the same resources, the platform caps the work a single transaction may do. The number of records a transaction can retrieve from the database is one of those caps, at 50,000 rows, and it exists precisely to stop one tenant's query from consuming shared capacity.

Why the other options are wrong

  • A. There is no limit on how many methods a class may declare.
  • C. There is no cap on the number of active Apex classes, only on total code size.
  • D. There is no governor on loop iterations as such. What constrains a loop is the CPU time and the queries or DML performed inside it.

Question 32

Which two statements are acceptable for a developer to use inside procedural loops? (Choose two.)

  1. delete contactList;
  2. contactList.remove(i);
  3. Contact con = new Contact();
  4. Account a = [SELECT Id, Name FROM Account WHERE Id = :con.AccountId LIMIT 1];
Show answer and explanation

Correct answer: B, C. contactList.remove(i);; Contact con = new Contact();

The two statements that are safe inside a loop are the ones that do not touch the database. Instantiating a Contact simply allocates an object in memory, and removing an element from a list by index is an in-memory list operation. Neither consumes a governor limit that scales with iterations.

Why the other options are wrong

  • A. A delete statement inside a loop issues one DML call per iteration and will hit the 150 DML statement limit. Records should be collected and deleted once after the loop.
  • D. A SOQL query inside a loop is the classic governor limit failure. It burns one of the 100 queries per iteration.

Question 33

Which approach should be used to provide test data for a test class?

  1. Query for existing records in the database.
  2. Execute anonymous code blocks that create data.
  3. Use a test data factory class to create test data.
  4. Access data in @TestVisible class variables.
Show answer and explanation

Correct answer: C. Use a test data factory class to create test data.

A test data factory is a dedicated class that builds the records tests need, so setup logic is written once and reused across the whole test suite. Tests stay isolated from org data, remain valid when required fields change because only the factory has to be updated, and each test still runs against data it created itself.

Why the other options are wrong

  • A. Querying existing records makes tests depend on org data, which is unavailable by default and differs between orgs, so tests become fragile.
  • B. Anonymous blocks are run manually and are not part of the test run, so they cannot supply data to a test method.
  • D. @TestVisible only widens access to private members. It does not create records.

Question 34

A developer needs to provide a way to mass edit, update, and delete records from a list view. In which two ways can this be accomplished? (Choose two.)

  1. Create a new Visualforce page and Apex Controller for the list view that provides mass edit, update, and delete functionality.
  2. Download a managed package from the AppExchange that provides customizable Enhanced List Views and buttons.
  3. Download an unmanaged package from the AppExchange that provides customizable mass edit, update, and delete functionality.
  4. Configure the user interface and enable both inline editing and enhanced lists.
Show answer and explanation

Correct answer: A, C. Create a new Visualforce page and Apex Controller for the list view that provides mass edit, update, and delete functionality; Download an unmanaged package from the AppExchange that provides customizable mass edit, update, and delete functionality.

Two routes deliver the capability. A custom Visualforce page with an Apex controller can present the records from the list view and handle mass edit, update and delete. Alternatively an unmanaged package from the AppExchange supplies that functionality as source that the org can then customise, which is what makes it a fit when the behaviour has to be adapted.

Why the other options are wrong

  • B. Managed package code is locked and cannot be customised, so it does not meet a requirement for customisable functionality.
  • D. Inline editing and enhanced lists allow editing several records of the same type in a list view, but they do not provide mass delete or the broader mass update the requirement describes.

Question 35

Why would a developer consider using a custom controller over a controller extension?

  1. To increase the SOQL query governor limits.
  2. To implement all of the logic for a page and bypass default Salesforce functionality
  3. To leverage built-in functionality of a standard controller
  4. To enforce user sharing settings and permissions
Show answer and explanation

Correct answer: B. To implement all of the logic for a page and bypass default Salesforce functionality

A custom controller replaces the standard controller entirely, so the developer writes all of the logic for the page and none of the default Salesforce record handling applies. An extension, by contrast, exists to add to a controller that is already doing the standard work. Wanting full control and no default behaviour is the reason to choose a custom controller.

Why the other options are wrong

  • A. Governor limits are fixed by the platform. No controller choice raises them.
  • C. Leveraging standard controller behaviour is the reason to use an extension, which is the opposite of this choice.
  • D. A custom controller runs in system mode by default and ignores user permissions and field level security unless it is declared with sharing.

Question 36

Which situation prevents a developer from setting sharing rules for a custom object?

  1. The object's Sharing Settings is set to Public Read/Write.
  2. The object is on the detail side of a Master-Detail relationship.
  3. The developer is not a System Administrator.
  4. The object is referenced in an Owner field of a Master-Detail relationship.
Show answer and explanation

Correct answer: B. The object is on the detail side of a Master-Detail relationship.

A detail record has no owner and no sharing settings of its own. Its access is entirely inherited from its master record, so the platform does not offer sharing rules or organisation-wide defaults for an object on the detail side of a master-detail relationship.

Why the other options are wrong

  • A. Public Read/Write is the most permissive default, so sharing rules are unnecessary, but nothing prevents them from being defined.
  • C. Sharing rules are administered with the Manage Sharing permission. This is a permission question rather than something that makes the setting unavailable on the object.
  • D. Record owners are Users. There is no Owner field created by a master-detail relationship, because detail records have no owner at all.

Question 37

A developer is asked to set a picklist field to `˜Monitor' on any new Leads owned by a subnet of Users. How should the developer implement this request?

  1. Create an after insert Lead trigger.
  2. Create a before insert Lead trigger.
  3. Create a Lead Workflow Rule Field Update.
  4. Create a Lead formula field.
Show answer and explanation

Correct answer: B. Create a before insert Lead trigger.

The value has to be on the record when it is first saved, and the condition depends on who owns the record, so the logic runs on insert. A before insert trigger can set the picklist directly on the records in Trigger.new with no additional DML, because the records have not been written yet. That makes it the efficient place to stamp a field value during creation.

Why the other options are wrong

  • A. An after insert trigger sees committed records, so changing a field would require a second DML statement on the same records and is wasteful.
  • C. A workflow field update also writes after the initial save and triggers a second save cycle. It is the older declarative route and does not match the stated design.
  • D. A formula field is calculated on read and cannot be edited or stored, so it cannot set a picklist value.

Question 38

Which two statements are true about Apex code executed in Anonymous Blocks? (Choose two.)

  1. The code runs with the permissions of the user specified in the runAs() statement.
  2. The code runs with the permissions of the logged in user.
  3. The code runs in system mode having access to all objects and fields.
  4. All DML operations are automatically rolled back.
  5. Successful DML operations are automatically committed.
Show answer and explanation

Correct answer: B, E. The code runs with the permissions of the logged in user; Successful DML operations are automatically committed.

Unlike classes and triggers, an anonymous block executes as the logged in user, so object and field permissions apply and the block can even fail to compile if the user lacks access to something it references. And the transaction behaves normally, meaning DML that succeeds is committed when the block finishes.

Why the other options are wrong

  • A. runAs() is only available inside test methods. It has no effect in an anonymous block.
  • C. System mode is how classes and triggers run by default. Anonymous Apex is the exception and runs in user mode.
  • D. Automatic rollback is test behaviour. An anonymous block commits its successful DML.

Question 39

Universal Containers (UC) uses a custom object called Vendor. The Vendor custom object has a Master-Detail relationship with the standard Account object. Based on some internal discussions, the UC administrator tried to change the Master-Detail relationship to a Lookup relationship but was not able to do so. What is a possible reason that this change was not permitted?

  1. The Vendor records have existing values in the Account object.
  2. The Account object is included on a workflow on the Vendor object.
  3. The Account records contain Vendor roll-up summary fields.
  4. The Vendor object must use a Master-Detail field for reporting.
Show answer and explanation

Correct answer: C. The Account records contain Vendor roll-up summary fields.

Roll-up summary fields only work over a master-detail relationship. If Account carries roll-up summary fields that aggregate Vendor records, converting the relationship to a lookup would leave those fields with no valid source, so the platform blocks the change until the roll-ups are deleted.

Why the other options are wrong

  • A. Existing data in the relationship does not prevent the conversion. Master-detail can be changed to lookup with records in place, subject to the other restrictions.
  • B. A workflow referencing the objects does not block a relationship type change.
  • D. Reporting works across lookup relationships too, so there is no reporting requirement forcing master-detail.

Question 40

A developer has a requirement to create an Order when an Opportunity reaches a 'Closed-Won' status. Which tool should be used to implement this requirement?

  1. Lightning Component
  2. Apex Trigger
  3. Lightning Flow
  4. Process Builder
Show answer and explanation

Correct answer: D. Process Builder

Creating an Order when the Opportunity reaches Closed-Won is a record change firing a record creation, which Process Builder handles directly with a Create a Record action and criteria on the stage field. It is the declarative tool that matches the requirement without code.

Why the other options are wrong

  • A. A Lightning component renders an interface and only runs when a user opens it, so nothing happens automatically.
  • B. An Apex trigger would work but writes code where a declarative tool suffices.
  • C. Lightning Flow is the name of the automation product family rather than a tool selected to build this. The builder that would be chosen is Process Builder for this scenario.

Question 41

A developer needs to update an unrelated object when a record gets saved. Which two trigger types should the developer create? (Choose two.)

  1. after insert
  2. before update
  3. before insert
  4. after update
Show answer and explanation

Correct answer: A, D. after insert; after update

Updating a different object requires DML, and DML on another record is done in an after trigger so the triggering records are already committed and have their IDs. Since the requirement is to act whenever the record is saved, that covers both creation and modification, so after insert and after update are the two events.

Why the other options are wrong

  • B. A before trigger is for modifying the triggering record itself. Performing DML on another object there risks acting on a save that later fails.
  • C. The same applies to before insert, and the new records have no IDs yet, so an unrelated object cannot reference them.

Question 42

A newly hired developer discovers that there are multiple triggers on the case object. What should the developer consider when working with triggers?

  1. Developers must dictate the order of trigger execution.
  2. Trigger execution order is based on creation date and time.
  3. Unit tests must specify the trigger being tested.
  4. Trigger execution order is not guaranteed for the same sObject.
Show answer and explanation

Correct answer: D. Trigger execution order is not guaranteed for the same sObject.

If more than one trigger is defined on an object for the same event, Salesforce does not guarantee the order in which they execute. That is the key consideration when inheriting an object that already carries several triggers, and it is the reason the one-trigger-per-object pattern exists.

Why the other options are wrong

  • A. Developers cannot dictate execution order across separate triggers. They can only control ordering by consolidating the logic into a single trigger.
  • B. Order is not determined by creation date and time, and relying on it would be unsafe even if it happened to correlate.
  • C. Unit tests exercise triggers by performing DML. There is no way, and no need, to name the trigger under test.

Question 43

Given the code below, what can be done so that recordCount can be accessed by a test class, but not by a non-test class?

  1. Change recordCount from private to public.
  2. Add the SeeAllData annotation to the test class.
  3. Add the TestVisible annotation to recordCount.
  4. Add the TestVisible annotation to the MyController class.
Show answer and explanation

Correct answer: C. Add the TestVisible annotation to recordCount.

The TestVisible annotation applied to a private or protected member lets test methods reach it while leaving it inaccessible to ordinary code. Putting it on recordCount is therefore exactly the requirement: visible to a test class, still private to everything else.

Why the other options are wrong

  • A. Making it public exposes it to all code, not just tests.
  • B. SeeAllData controls whether tests can query org data. It has nothing to do with member visibility.
  • D. The annotation is applied to the member whose access is being widened, not to the class as a whole.

Question 44

What is the requirement for a class to be used as a custom Visualforce controller?

  1. Any top-level Apex class that has a constructor that returns a PageReference
  2. Any top-level Apex class that extends a PageReference
  3. Any top-level Apex class that has a default, no-argument constructor
  4. Any top-level Apex class that implements the controller interface
Show answer and explanation

Correct answer: C. Any top-level Apex class that has a default, no-argument constructor

When a page names a custom controller, the platform has to instantiate that class with no arguments, so the class must be a top-level Apex class with a default no-argument constructor. Nothing else is required: no interface, no particular return type.

Why the other options are wrong

  • A. A constructor cannot return a PageReference. Constructors return nothing, and action methods are what return PageReference.
  • B. PageReference is not extendable, and a controller does not derive from it.
  • D. There is no controller interface to implement. Standard controller extensions take a StandardController argument, but that is a different scenario.

Question 45

A Platform Developer needs to write an Apex method that will only perform an action if a record is assigned to a specific Record Type. Which two options allow the developer to dynamically determine the ID of the required Record Type by its name? (Choose two.)

  1. Make an outbound web services call to the SOAP API.
  2. Hardcode the ID as a constant in an Apex class.
  3. Use the getRecordTypeInfosByName() method in the DescribeSObjectResult class.
  4. Execute a SOQL query on the RecordType object.
Show answer and explanation

Correct answer: C, D. Use the getRecordTypeInfosByName() method in the DescribeSObjectResult class; Execute a SOQL query on the RecordType object.

Both supported ways of resolving a Record Type ID at run time avoid hardcoding. The describe layer offers getRecordTypeInfosByName() on DescribeSObjectResult, which returns a map keyed by record type name, and a plain SOQL query against the RecordType object filtered on Name and SobjectType returns the same ID. Either keeps the code portable between orgs.

Why the other options are wrong

  • A. Calling the SOAP API from Apex to read metadata that describe calls already expose is unnecessary and would consume a callout.
  • B. Hardcoding the ID is exactly what the requirement to determine it dynamically rules out, and IDs differ between orgs.

Question 46

A developer needs to create an audit trail for records that are sent to the recycle bin. Which type of trigger is most appropriate to create?

  1. after delete
  2. after undelete
  3. before undelete
  4. before delete
Show answer and explanation

Correct answer: A. after delete

Records sent to the recycle bin are deleted, and the audit entry has to record what was actually removed. An after delete trigger fires once the delete has succeeded, so it only writes audit records for deletions that really happened and it has the final field values available in Trigger.old.

Why the other options are wrong

  • B. after undelete fires when a record is restored from the recycle bin, which is the opposite event.
  • C. There is no before undelete trigger event in Apex.
  • D. A before delete trigger fires before the delete is committed, so the delete could still fail and leave a false audit entry.

Question 47

A developer is debugging the following code to determine why Accounts are not being created. Account a = new Account(Name = 'A'); Database.insert(a, false); How should the code be altered to help debug the issue?

  1. Add a System.debug() statement before the insert method.
  2. Collect the insert method return value in a SaveResult record.
  3. Set the second insert method parameter to TRUE.
  4. Add a try/catch around the insert method.
Show answer and explanation

Correct answer: B. Collect the insert method return value in a SaveResult record.

Database.insert with allOrNone set to false lets individual records fail silently, which is exactly why nothing appears to happen. Capturing the returned SaveResult lets the developer inspect isSuccess() and read getErrors(), which reveals why the Account was rejected.

Why the other options are wrong

  • A. A debug statement before the insert shows the input, not the reason the save failed.
  • C. Setting the flag to true makes the failure throw, which does surface an error, but the question asks how to debug the issue and the SaveResult reports the specific errors.
  • D. With allOrNone false no exception is thrown, so a catch block never runs and the errors stay hidden.

Question 48

Using DescribeSObjectResult, which Apex method can a developer use to determine if the current user can edit records for an object?

  1. canUpdate()
  2. canEdit()
  3. isUpdateable()
  4. isEditable()
Show answer and explanation

Correct answer: C. isUpdateable()

The describe result exposes access checks as isAccessible(), isCreateable(), isUpdateable() and isDeletable(). Edit access on an object is therefore tested with isUpdateable(), which is the method name the platform uses.

Why the other options are wrong

  • A. There is no canUpdate() method on DescribeSObjectResult.
  • B. There is no canEdit() method either.
  • D. isEditable() does not exist. The naming convention is isUpdateable().

Question 49

What are two ways for a developer to execute tests in an org? (Choose two.)

  1. Tooling API
  2. Developer Console
  3. Metadata API
  4. Bulk API
Show answer and explanation

Correct answer: A, B. Tooling API; Developer Console

Tests can be executed from the Developer Console, which offers Run All and selective runs, and through the Tooling API, which is what IDEs and CI scripts call to queue test runs and read results.

Why the other options are wrong

  • C. The Metadata API deploys and retrieves components. It can run tests as part of a deployment but is not a way to execute tests in an org on demand.
  • D. The Bulk API loads and queries records. It has no test capability.

Question 50

The values 'High', 'Medium', and 'Low' are identified as common values for multiple picklists across different objects. What is an approach a developer can take to streamline maintenance of the picklists and their values, while also restricting the values to the ones mentioned above?

  1. Create the Picklist on each object and use a Global Picklist Value Set containing the values.
  2. Create the Picklist on each object as a required field and select "Display values alphabetically, not in the order entered".
  3. Create the Picklist on each object and add a validation rule to ensure data integrity.
  4. Create the Picklist on each object and select "Restrict picklist to the values defined in the value set".
Show answer and explanation

Correct answer: A. Create the Picklist on each object and use a Global Picklist Value Set containing the values.

A global picklist value set defines the values once and is then used by picklist fields on any object. Editing the set updates every field that uses it, and fields based on a global value set are automatically restricted, so no value outside the set can be saved.

Why the other options are wrong

  • B. Alphabetical display and requiredness change presentation and entry, not the shared maintenance of values.
  • C. A validation rule per object is more to maintain and does not centralise the value list.
  • D. Restricting the picklist prevents values outside the list, but each field still has its own copy of the values, so maintenance is not streamlined.

50 questions in. Want the rest? The first half of the pack, free by email · The full pack

Question 51

For which three items can a trace flag be configured? (Choose three.)

  1. Apex Trigger
  2. Apex Class
  3. Process Builder
  4. User
  5. Visualforce
Show answer and explanation

Correct answer: A, B, D. Apex Trigger; Apex Class; User

A trace flag can be configured against a user, an Apex class or an Apex trigger. The user trace captures everything that user does, while class and trigger trace flags let a developer raise log levels for just that code, which is useful when the entry point is a scheduled job or an integration rather than an interactive session.

Why the other options are wrong

  • C. Process Builder is not an entity a trace flag can target. Its activity shows up in the logs of whatever transaction invoked it.
  • E. Visualforce is a log category whose level is set inside a debug level. It is not something a trace flag is configured on.

Question 52

A developer has the following requirements: * Calculate the total amount on an Order. * Calculate the line amount for each Line Item based on quantity selected and price. * Move Line Items to a different Order if a Line Item is not in stock. Which relationship implementation supports these requirements?

  1. Order has a Lookup field to Line Item and there can be many Line Items per Order.
  2. Line Item has a Lookup field to Order and there can be many Line Items per Order.
  3. Order has a Master-Detail field to Line Item and there can be many Line Items per Order.
  4. Line Item has a Master-Detail field to Order and the Master can be re-parented.
Show answer and explanation

Correct answer: D. Line Item has a Master-Detail field to Order and the Master can be re-parented.

Rolling the total amount up to the Order requires a roll-up summary, which needs a master-detail relationship with Line Item as the detail. Moving a Line Item to a different Order then requires the Allow reparenting option on that relationship, which permits the child to be pointed at a new parent. The line amount itself is a formula on the Line Item.

Why the other options are wrong

  • A. The relationship field belongs on the child, and a lookup on the parent cannot express many children.
  • B. A lookup supports many line items but gives no roll-up summary, so the order total cannot be calculated declaratively.
  • C. The master-detail field must be created on the detail object. Putting it on Order inverts the relationship.

Question 53

Which tool allows a developer to send requests to the Salesforce REST APIs and view the responses?

  1. REST resource path URL
  2. Workbench REST Explorer
  3. Developer Console REST tab
  4. Force.com IDE REST Explorer tab
Show answer and explanation

Correct answer: B. Workbench REST Explorer

Workbench includes a REST Explorer under its Utilities menu that lets a developer choose an HTTP method, enter a resource path, send the request against the authenticated org and read the raw response. It is the tool built for exactly this.

Why the other options are wrong

  • A. A resource path URL is the address of an endpoint, not a tool for issuing requests and inspecting responses.
  • C. The Developer Console has no REST tab. It offers the Query Editor and anonymous Apex execution.
  • D. The Force.com IDE has no REST Explorer tab.

Question 54

Which two strategies should a developer use to avoid hitting governor limits when developing in a multi-tenant environment? (Choose two.)

  1. Use collections to store all fields from a related object and not just minimally required fields.
  2. Use methods from the "Limits" class to monitor governor limits.
  3. Use SOQL for loops to iterate data retrieved from queries that return a high number of rows.
  4. Use variables within Apex classes to store large amounts of data.
Show answer and explanation

Correct answer: B, C. Use methods from the "Limits" class to monitor governor limits; Use SOQL for loops to iterate data retrieved from queries that return a high number of rows.

Two habits keep code within limits. The Limits class exposes methods such as getQueries and getDmlRows so code can check consumption at run time and behave defensively. And a SOQL for loop streams query results in batches of 200 instead of loading everything into one collection, which is what keeps large result sets from exhausting heap.

Why the other options are wrong

  • A. Querying every field rather than only the ones needed loads more data into memory and pushes heap usage up.
  • D. Holding large amounts of data in class variables is precisely what causes heap limit exceptions.

Question 55

A developer needs to join data received from an integration with an external system with parent records in Salesforce. The data set does not contain the Salesforce IDs of the parent records, but it does have a foreign key attribute that can be used to identify the parent. Which action will allow the developer to relate records in the data model without knowing the Salesforce ID?

  1. Create and populate a custom field on the parent object marked as Unique.
  2. Create a custom field on the child object of type External Relationship.
  3. Create and populate a custom field on the parent object marked as an External ID.
  4. Create a custom field on the child object of type Foreign Key.
Show answer and explanation

Correct answer: C. Create and populate a custom field on the parent object marked as an External ID.

Marking a custom field on the parent as an External ID lets the platform match on that value instead of a Salesforce ID. The integration's foreign key is stored there, and child records can then be related, or upserted, by referencing the parent through the external ID field, so no Salesforce IDs need to be known in advance.

Why the other options are wrong

  • A. Unique enforces that no two records share a value but does not make the field usable as a matching key for relating or upserting records.
  • B. There is no External Relationship field type on standard or custom objects.
  • D. There is no Foreign Key field type in Salesforce. Relationships are Lookup or Master-Detail.

Question 56

A developer uses a loop to check each Contact in a list. When a Contact with the Title of 'Boss' is found, the Apex method should jump to the first line of code outside of the for loop. Which Apex solution will let the developer implement this requirement?

  1. return;
  2. continue;
  3. break;
  4. System.assert(false);
Show answer and explanation

Correct answer: C. break;

break exits the loop immediately and execution resumes at the first statement after the loop, which is exactly what the requirement describes.

Why the other options are wrong

  • A. return exits the whole method, so the code after the loop never runs.
  • B. continue skips to the next iteration rather than leaving the loop.
  • D. An assertion that fails throws an exception. It is a test construct and would abort the transaction rather than exiting the loop.

Question 57

A developer needs to find information about @future methods that were invoked. From which system monitoring feature can the developer see this information?

  1. Scheduled Jobs
  2. Apex Jobs
  3. Background Jobs
  4. Asynchronous Jobs
Show answer and explanation

Correct answer: B. Apex Jobs

Future methods are asynchronous Apex, and every asynchronous Apex invocation is recorded in Apex Jobs in Setup, along with its status, submitter and any error. That is where a developer looks to see whether a future method ran and what happened to it.

Why the other options are wrong

  • A. Scheduled Jobs lists jobs waiting on a schedule, which future methods are not.
  • C. There is no Background Jobs monitoring page for Apex.
  • D. There is no page called Asynchronous Jobs. The page that covers asynchronous work is Apex Jobs.

Question 58

In order to override a standard action with a Visualforce page, which attribute must be defined in the <apex:page> tag?

  1. pageReference
  2. override
  3. controller
  4. standardController
Show answer and explanation

Correct answer: D. standardController

To be eligible as an override for a standard action, the Visualforce page has to be associated with the object that owns the action, and that association is made with the standardController attribute. A page without it does not appear in the list of available overrides.

Why the other options are wrong

  • A. There is no pageReference attribute on apex:page. PageReference is a return type used in controller methods.
  • B. There is no override attribute. The override is configured in Setup on the object's buttons and links.
  • C. controller names a custom controller and does not bind the page to a standard object, so the page cannot override that object's action.

Question 59

What are two ways a developer can get the status of an enqueued job for a class that implements the queueable interface? (Choose two.)

  1. View the Apex Jobs Page
  2. View the Apex Status Page
  3. Query the AsyncApexJob object
  4. View the Apex Flex Queue
Show answer and explanation

Correct answer: A, C. View the Apex Jobs Page; Query the AsyncApexJob object

An enqueued Queueable job is tracked as an AsyncApexJob record, so its status can be read either by querying AsyncApexJob in SOQL or by opening the Apex Jobs page in Setup, which is the user interface over the same data.

Why the other options are wrong

  • B. There is no Apex Status page in Setup.
  • D. The Apex Flex Queue holds Batch Apex jobs that are waiting to start. Queueable jobs do not appear there.

Question 60

When using SalesforceDX, what does a developer need to enable to create and manage scratch orgs?

  1. Production
  2. Environment Hub
  3. Dev Hub
  4. Sandbox
Show answer and explanation

Correct answer: C. Dev Hub

Scratch orgs are created and managed against a Dev Hub. The Dev Hub is enabled in a production or business org and holds the scratch org allocation, so the CLI authenticates to it before it can create, list or delete scratch orgs.

Why the other options are wrong

  • A. Production is where the Dev Hub is switched on, but production itself is not the feature that has to be enabled.
  • B. Environment Hub manages connected orgs for partners. It does not provision scratch orgs.
  • D. A sandbox cannot host a Dev Hub and plays no part in the scratch org lifecycle.

Question 61

Which Salesforce feature allows a developer to see when a user last logged in to Salesforce if real-time notification is not required?

  1. Event Monitoring Log
  2. Calendar Events
  3. Developer Log
  4. Asynchronous Data Capture Events
Show answer and explanation

Correct answer: A. Event Monitoring Log

Event Monitoring exposes EventLogFile records covering login and other user activity, which a developer can query or download to see when a user last logged in. The logs are generated on a delay, which is why the question specifies that real-time notification is not required.

Why the other options are wrong

  • B. Calendar Events are meetings and appointments, unrelated to authentication.
  • C. There is no Developer Log feature. Debug logs capture transactions, not login history.
  • D. Change Data Capture publishes record change events in near real time and does not cover logins.

Question 62

A Licensed_Professional__c custom object exists in the system with two Master-Detail fields for the following objects: Certification__c and Contact. Users with the `Certification Representative` role can access the Certification records they own and view the related Licensed Professionals records, however users with the `Sales Representative` role report they cannot view any Licensed Professional records even though they own the associated Contact record. What are two likely causes of users in the `Sales Representative` role not being able to access the Licensed Professional records? (Choose two.)

  1. The organization has a private sharing model for Certification__c. and Certification__c is the primary relationship in the Licensed_Professional__c object.
  2. The organization's sharing rules for Licensed_Professional__c have not finished their recalculation process.
  3. The organization recently modified the Sales Representative role to restrict Read/Write access to Licensed_Professional__c.
  4. The organization has a private sharing model for Certification__c, and Contact is the primary relationship in the Licensed_Professional__c object.
Show answer and explanation

Correct answer: A, B. The organization has a private sharing model for Certification__c. and Certification__c is the primary relationship in the Licensed_Professional__c object; The organization's sharing rules for Licensed_Professional__c have not finished their recalculation process.

When an object has two master-detail relationships, the first one created is the primary and it controls the record's sharing. If Certification__c is the primary master and its sharing model is private, access to a Licensed Professional follows the Certification rather than the Contact, which explains why Certification Representatives can see the records and Sales Representatives cannot. Sharing recalculation still running is the other plausible cause, because access is not fully applied until it completes.

Why the other options are wrong

  • C. Access to an object is granted through profiles and permission sets, not by editing a role. A role affects record sharing hierarchy, not object permissions.
  • D. This is the mirror image of the correct cause. If Contact were the primary relationship the Sales Representatives who own the Contact would have access, which is not what is happening.

Question 63

Universal Containers stores Orders and Line Items in Salesforce. For security reasons, financial representatives are allowed to see information on the Order such as order amount, but they are not allowed to see the Line Items on the Order. Which type of relationship should be used?

  1. Direct Lookup
  2. Indirect Lookup
  3. Master-Detail
  4. Lookup
Show answer and explanation

Correct answer: D. Lookup

A detail record inherits the sharing and access of its master, so if Line Items were details of the Order, anyone who could see the Order would automatically see the Line Items. A lookup keeps the Line Item's access independent, which is what allows financial representatives to see the Order and its amount while being denied the Line Items.

Why the other options are wrong

  • A. Direct lookup relationships are used on external objects to point at a Salesforce object. This is standard object data.
  • B. Indirect lookups also belong to external objects and match on an External ID.
  • C. Master-detail is what causes the problem, because the children inherit the parent's access.

Question 64

Which three statements are true regarding custom exceptions in Apex? (Choose three.)

  1. A custom exception class must extend the system Exception class.
  2. A custom exception class can implement one or many interfaces.
  3. A custom exception class cannot contain member variables or methods.
  4. A custom exception class name must end with "Exception".
  5. A custom exception class can extend other classes besides the Exception class.
Show answer and explanation

Correct answer: A, B, D. A custom exception class must extend the system Exception class; A custom exception class can implement one or many interfaces; A custom exception class name must end with "Exception".

Three rules apply. A custom exception must extend Exception or another exception class, its name must end in Exception, and like any Apex class it may implement one or more interfaces.

Why the other options are wrong

  • C. A custom exception class can declare member variables, methods and constructors just like any other class.
  • E. Apex has no multiple inheritance, and an exception class must derive from the exception hierarchy, so it cannot extend an unrelated class.

Question 65

Which two practices should be used for processing records in a trigger? (Choose two.)

  1. Use a Map to reduce the number of SOQL calls.
  2. Use @future methods to handle DML operations.
  3. Use a Set to ensure unique values in a query filter.
  4. Use (callout=true) to update an external system.
Show answer and explanation

Correct answer: A, C. Use a Map to reduce the number of SOQL calls; Use a Set to ensure unique values in a query filter.

Two idioms keep a trigger bulk safe. Collecting related records into a Map keyed by ID lets the trigger issue one query and then look each record up in memory instead of querying inside the loop. And building a Set of the IDs or values to filter on removes duplicates and gives a single bind variable for one query. Both cut the number of SOQL calls to a constant.

Why the other options are wrong

  • B. A future method does not make DML safe or cheaper. It adds asynchronous complexity, cannot return data, and has its own limits.
  • D. callout=true enables callouts from a future method. Updating an external system is not a general practice for processing records in a trigger.

Question 66

Which action can a developer take to reduce the execution time of the following code?

  1. Put the Account loop inside the Contact loop.
  2. Create an Apex helper class for SOQL.
  3. Add a GROUP BY clause to the Contact SOQL.
  4. Use a Map<Id List<Contact> for allContacts.
Show answer and explanation

Correct answer: D. Use a Map<Id List<Contact> for allContacts.

The slow part is scanning every Contact for each Account, which makes the work grow with the product of the two collections. Building a Map keyed by Account ID whose value is the list of that account's Contacts turns the inner scan into a single lookup, so the code passes over the Contacts once and then reads from the map. That is the standard fix for a nested loop over related records.

Why the other options are wrong

  • A. Swapping the nesting keeps the same number of comparisons, so it changes nothing.
  • B. Moving queries into a helper class organises code but performs the same work.
  • C. GROUP BY produces aggregate rows rather than the Contact records the code needs.

Question 67

How should a developer prevent a recursive trigger?

  1. Use a "one trigger per object" pattern.
  2. Use a static Boolean variable.
  3. Use a trigger handler.
  4. Use a private Boolean variable.
Show answer and explanation

Correct answer: B. Use a static Boolean variable.

A static Boolean variable holds its value for the life of the transaction, so the trigger can set it the first time it runs and check it on re-entry to skip the logic. That transaction-scoped flag is the standard guard against recursion caused by a trigger's own DML firing the trigger again.

Why the other options are wrong

  • A. One trigger per object controls ordering and keeps logic in one place. It does not stop that single trigger from firing itself again.
  • C. A trigger handler organises code. Recursion still has to be prevented by a flag inside it.
  • D. A private instance variable is recreated on each trigger invocation, so its value does not survive to the next run and it cannot detect re-entry.

Question 68

A developer can use the debug log to see which three types of information? (Choose three.)

  1. HTTP callouts to external systems
  2. Database changes
  3. Resource usage and limits
  4. User login events
  5. Actions triggered by time-based workflow
Show answer and explanation

Correct answer: A, B, C. HTTP callouts to external systems; Database changes; Resource usage and limits

A debug log records the database operations performed in the transaction, HTTP callouts made to external systems, and the resources consumed against governor limits. Those are three of the documented categories of information a log contains.

Why the other options are wrong

  • D. Login events are recorded in the Login History, which is a separate audit trail rather than the debug log.
  • E. The debug log explicitly does not include information from actions triggered by time-based workflow.

Question 69

A developer has the following class and trigger code. Which code segment should a developer insert at the XXX to set the baseCost variable to the value of the class variable smokerCharge?

  1. InsuranceRates.smokerCharge
  2. rates.getSmokerCharge()
  3. ContactTrigger.InsuranceRates.smokerCharge
  4. rates.smokerCharge
Show answer and explanation

Correct answer: A. InsuranceRates.smokerCharge

smokerCharge is a static variable on the InsuranceRates class, and a static member is associated with the class rather than any instance. Apex requires it to be referenced through the class name, so InsuranceRates.smokerCharge is the correct expression and is the only option that compiles.

Why the other options are wrong

  • B. There is no getSmokerCharge() accessor in the class, and reaching a static through an instance is not how Apex exposes it.
  • C. Prefixing the trigger name is not valid. InsuranceRates is a top-level class, not a member of the trigger.
  • D. A static variable cannot be accessed through an instance of the class in Apex. This is the specific rule the question is testing.

Question 70

What are two valid options for iterating through each Account in the collection List<Account> named AccountList? (Choose two.)

  1. for (Account theAccount : AccountList) {"¦}
  2. for(AccountList) {"¦}
  3. for (List L : AccountList) {"¦}
  4. for (Integer i=0; i < AccountList.Size(); i++) {"¦}
Show answer and explanation

Correct answer: A, D. for (Account theAccount : AccountList) {"¦}; for (Integer i=0; i < AccountList.Size(); i++) {"¦}

Apex offers two ways to walk a list. The enhanced for loop declares a variable of the element type and iterates the collection directly, which is the idiomatic form. The traditional counted loop uses an Integer index bounded by the list's size() and reaches each element by position. Both are valid for a List<Account>.

Why the other options are wrong

  • B. for(AccountList) is not valid syntax. A for loop needs either an iteration variable and a collection or the three-part counted form.
  • C. The loop variable type has to match the element type. The elements are Account records, not List objects, so this does not compile.

Question 71

A developer must provide a custom user interface when users edit a Contact. Users must be able to use the interface in Salesforce Classic and Lightning Experience. What should the developer do to provide the custom user interface?

  1. Override the Contact's Edit button with a Visualforce page in Salesforce Classic and a Lightning component in Lightning Experience.
  2. Override the Contact's Edit button with a Visualforce page in Salesforce Classic and a Lightning page in Lightning Experience.
  3. Override the Contact's Edit button with a Lightning component in Salesforce Classic and a Lightning component in Lightning Experience.
  4. Override the Contact's Edit button with a Lightning page in Salesforce Classic and a Visualforce page in Lightning Experience.
Show answer and explanation

Correct answer: A. Override the Contact's Edit button with a Visualforce page in Salesforce Classic and a Lightning component in Lightning Experience.

A button override is configured separately for Salesforce Classic and Lightning Experience. Lightning components cannot override a button in Classic, so the Classic override uses a Visualforce page while the Lightning Experience override uses a Lightning component. Setting both gives every user the custom interface.

Why the other options are wrong

  • B. A Lightning page cannot be used to override a button. Only a Visualforce page or a Lightning component can.
  • C. A Lightning component is not available as a Classic override, so Classic users would keep the standard edit screen.
  • D. The Lightning page is invalid as an override, and the two interfaces are the wrong way round.

Question 72

Which three code lines are required to create a Lightning component on a Visualforce page? (Choose three.)

  1. $Lightning.useComponent
  2. <apex:slds/>
  3. $Lightning.use
  4. <apex:includeLightning/>
  5. $Lightning.createComponent
Show answer and explanation

Correct answer: C, D, E. $Lightning.use; <apex:includeLightning/>; $Lightning.createComponent

Three pieces are required. The <apex:includeLightning/> tag loads the Lightning Out JavaScript library into the page. $Lightning.use() then references the Lightning application that grants access to the components. Finally $Lightning.createComponent() instantiates the component into a DOM element on the page.

Why the other options are wrong

  • A. There is no $Lightning.useComponent function. The two functions are use and createComponent.
  • B. <apex:slds/> pulls in the Lightning Design System stylesheet. It is styling and is not required to run the component.

Question 73

A team of developers is working on a source-driven project that allows them to work independently, with many different org configurations. Which type of Salesforce orgs should they use for their development?

  1. Developer orgs
  2. Developer sandboxes
  3. Full Copy sandboxes
  4. Scratch orgs
Show answer and explanation

Correct answer: D. Scratch orgs

Scratch orgs are disposable, source-driven environments created from a definition file, so each developer can spin up an org with whatever edition, features and settings their work needs and discard it afterwards. That independence and configurability is exactly what the team described requires.

Why the other options are wrong

  • A. Developer orgs are long-lived and are not created from source or thrown away per feature.
  • B. Developer sandboxes are copies of one production configuration, so they cannot offer many different org configurations.
  • C. Full Copy sandboxes are expensive, slow to refresh and mirror production, which is the opposite of independent per-developer configuration.

Question 74

What is a benefit of using an after insert trigger over using a before insert trigger?

  1. An after insert trigger allows a developer to bypass validation rules when updating fields on the new record.
  2. An after insert trigger allows a developer to insert other objects that reference the new record.
  3. An after insert trigger allows a developer to make a callout to an external service.
  4. An after insert trigger allows a developer to modify fields in the new record without a query.
Show answer and explanation

Correct answer: B. An after insert trigger allows a developer to insert other objects that reference the new record.

In a before insert trigger the records do not yet have IDs, because they have not been written to the database. An after insert trigger runs once the records are committed and their IDs are populated, so other records that need to reference the new records by ID can be created there. That is the defining benefit.

Why the other options are wrong

  • A. Validation rules run before the after trigger fires and cannot be bypassed by choosing a trigger timing.
  • C. Callouts from a trigger require an asynchronous method marked @future(callout=true) or a Queueable, in before or after alike.
  • D. Modifying fields on the triggering record without a query and without extra DML is the advantage of a before trigger, not an after trigger.

Question 75

A developer created this Apex trigger that calls MyClass.myStaticMethod: trigger myTrigger on Contact(before insert) { MyClass.myStaticMethod(trigger.new, trigger.oldMap); } The developer creates a test class with a test method that calls MyClass.myStaticMethod, resulting in 81% overall code coverage. What happens when the developer tries to deploy the trigger and two classes to production, assuming no other code exists?

  1. The deployment fails because no assertions were made in the test method.
  2. The deployment passes because both classes and the trigger were included in the deployment.
  3. The deployment passes because the Apex code has required (>75%) code coverage.
  4. The deployment fails because the Apex trigger has no code coverage.
Show answer and explanation

Correct answer: D. The deployment fails because the Apex trigger has no code coverage.

Overall coverage of 75 percent is only one of the deployment conditions. Salesforce also requires every trigger to have at least some coverage of its own, and this test never causes a Contact insert, so the trigger body never executes. With zero trigger coverage the deployment is rejected despite the 81 percent overall figure.

Why the other options are wrong

  • A. Assertions are strongly recommended but are not enforced by the deployment. A test with no assertions still counts toward coverage.
  • B. Including components in a deployment does not exempt them from the coverage requirements.
  • C. The overall percentage is sufficient, but the separate rule that each trigger needs coverage is not met.

75 questions in. Want the rest? The first half of the pack, free by email · The full pack

Question 76

Which three statements are true regarding trace flags? (Choose three.)

  1. Setting trace flags automatically cause debug logs to be generated.
  2. Logging levels override trace flags.
  3. Trace flags override logging levels.
  4. If active trace flags are not set, Apex tests execute with default logging levels.
  5. Trace flags can be set in the Developer Console, Setup, or using the Tooling API.
Show answer and explanation

Correct answer: C, D, E. Trace flags override logging levels; If active trace flags are not set, Apex tests execute with default logging levels; Trace flags can be set in the Developer Console, Setup, or using the Tooling API.

Class and trigger trace flags override the logging levels that are otherwise in effect, including those set by a user trace flag, but they do not by themselves cause a log to be written. If no active trace flag applies, Apex tests run with default logging levels. And trace flags can be created from the Developer Console, from Setup, or through the Tooling API.

Why the other options are wrong

  • A. Class and trigger trace flags override levels without generating logs. Setting a trace flag does not automatically produce one.
  • B. The precedence runs the other way. Trace flags override logging levels, not the reverse.

Question 77

Given the following Apex statement: Account myAccount = [SELECT Id, Name FROM Account]; What occurs when more than one Account is returned by the SOQL query?

  1. The variable, myAccount, is automatically cast to the List data type.
  2. The first Account returned is assigned to myAccount.
  3. The query fails and an error is written to the debug log.
  4. An unhandled exception is thrown and the code terminates.
Show answer and explanation

Correct answer: D. An unhandled exception is thrown and the code terminates.

Assigning a query directly to a single sObject variable requires the query to return exactly one row. When more than one comes back the runtime throws a QueryException saying the list has more than one row for assignment to sObject, and because nothing catches it the code terminates.

Why the other options are wrong

  • A. Apex does not silently change the variable's declared type. The assignment fails instead.
  • B. There is no implicit take-the-first behaviour. That has to be written explicitly with a list and an index.
  • C. The exception does appear in the log, but the significant outcome is that it is unhandled and stops execution rather than the code carrying on.

Question 78

A developer wants to store a description of a product that can be entered on separate lines by a user during product setup and later displayed on a Visualforce page for shoppers. Which field type should the developer choose to ensure that the description will be searchable in the custom Apex SOQL queries that are written?

  1. Text Area
  2. Text
  3. Text Area (Long)
  4. Text Area (Rich)
Show answer and explanation

Correct answer: A. Text Area

The description needs multiple lines and it has to be usable in SOQL filters. A Text Area accepts line breaks and, unlike the long variants, remains filterable in a WHERE clause. That combination is what makes it the right choice.

Why the other options are wrong

  • B. A plain Text field is a single line, so a user cannot enter separate lines.
  • C. Text Area (Long) allows multiple lines but cannot be filtered in a SOQL query, which fails the search requirement.
  • D. Text Area (Rich) stores markup and is likewise not filterable, and the embedded HTML would complicate display.

Question 79

Which option should a developer use to create 500 Accounts and make sure that duplicates are not created for existing Account Sites?

  1. Sandbox template
  2. Data Loader
  3. Data Import Wizard
  4. Salesforce-to-Salesforce
Show answer and explanation

Correct answer: C. Data Import Wizard

The Data Import Wizard handles up to 50,000 records, so 500 Accounts is well within range, and it offers built-in duplicate matching so existing records can be matched rather than duplicated. That combination of volume and duplicate prevention is what the requirement asks for.

Why the other options are wrong

  • A. A sandbox template controls which data a Full or Partial sandbox copies. It does not import records.
  • B. Data Loader handles far larger volumes but has no duplicate matching of its own. Preventing duplicates would require an External ID and an upsert.
  • D. Salesforce-to-Salesforce shares records between two orgs. It is not an import tool for a spreadsheet of accounts.

Question 80

Universal Containers (UC) decided it will not send emails to support personnel directly from Salesforce in the event that an unhandled exception occurs. Instead, UC wants an external system be notified of the error. What is the appropriate publish/subscribe logic to meet these requirements?

  1. Publish the error event using the addError() method and write a trigger to subscribe to the event and notify the external system.
  2. Publish the error event using the Eventbus.publish() method and have the external system subscribe to the event using CometD.
  3. Have the external system subscribe to the BatchApexError event, no publishing is necessary.
  4. Publish the error event using the addError() method and have the external system subscribe to the event using CometD.
Show answer and explanation

Correct answer: B. Publish the error event using the Eventbus.publish() method and have the external system subscribe to the event using CometD.

The requirement is a publish and subscribe design that reaches outside Salesforce. A platform event is published from Apex with EventBus.publish(), and an external system subscribes to the event channel over CometD to receive it. That delivers the notification without Salesforce sending any email.

Why the other options are wrong

  • A. addError() marks a record as failed in a trigger. It does not publish an event, and adding a trigger subscriber keeps the notification inside Salesforce.
  • C. BatchApexError only fires for failures in Batch Apex, so it does not cover unhandled exceptions generally, and something still has to publish for other error types.
  • D. addError() is still not a publishing mechanism, so there would be no event on the channel for the subscriber to receive.

Question 81

Which governor limit applies to all the code in an Apex transaction?

  1. Elapsed SOQL query time
  2. Number of classes called
  3. Number of new records created
  4. Elapsed CPU time
Show answer and explanation

Correct answer: D. Elapsed CPU time

Nearly all governor limits are counted per transaction, but CPU time is the one that accumulates across everything the transaction executes, including triggers, workflow, processes and all called Apex. It is the limit that applies to all the code in the transaction taken together.

Why the other options are wrong

  • A. There is a maximum SOQL query run time, but it is a static limitation on an individual query rather than a total across the transaction.
  • B. There is no limit on the number of classes called.
  • C. The limit is on DML rows and DML statements, not on a count of new records as a distinct governor.

Question 82

Universal Containers uses a simple Order Management app. On the Order Lines, the order line total is calculated by multiplying the item price with the quantity ordered. There is a Master-Detail relationship between the Order and the Order Lines object. What is the best practice to get the sum of all order line totals on the order header?

  1. Declarative Roll-Up Summaries App
  2. Roll-Up Summary field
  3. Process Builder
  4. Apex Trigger
Show answer and explanation

Correct answer: B. Roll-Up Summary field

Order Lines are the detail side of a master-detail relationship to Order, which is the exact condition a roll-up summary requires. A SUM roll-up on the order line total gives the header figure, maintained by the platform with no code and no automation to keep in step.

Why the other options are wrong

  • A. An AppExchange roll-up package exists for lookup relationships. It is unnecessary here because the native feature applies.
  • C. Process Builder would have to recalculate the total itself and can miss deletes.
  • D. A trigger is code where a declarative field already does the job correctly.

Question 83

Which two number expressions evaluate correctly? (Choose two.)

  1. Double d = 3.14159;
  2. Integer I = 3.14159;
  3. Decimal d = 3.14159;
  4. Long l = 3.14159;
Show answer and explanation

Correct answer: A, C. Double d = 3.14159;; Decimal d = 3.14159;

Only the types that hold fractional values accept a literal with a decimal point. Double and Decimal both do, so assigning 3.14159 to either is valid. Decimal is the type Apex uses for currency and number fields because it keeps precision, while Double is a floating point type.

Why the other options are wrong

  • B. Integer holds whole numbers only, so assigning a decimal literal is a compile error rather than a silent truncation.
  • D. Long is a 64 bit whole number type and likewise rejects a decimal literal.

Question 84

Which type of code represents the Model in the MVC architecture when using Apex and Visualforce pages?

  1. A Controller Extension method that saves a list of Account records
  2. Custom JavaScript that processes a list of Account records
  3. A list of Account records returned from a Controller Extension method
  4. A Controller Extension method that uses SOQL to query for a list of Account records
Show answer and explanation

Correct answer: C. A list of Account records returned from a Controller Extension method

The Model is the data itself. A list of Account records returned from a controller extension is exactly that: the sObject data the page will render. The methods that fetch or save it are Controller code, and the page markup is the View.

Why the other options are wrong

  • A. A method that saves records is logic acting on the data, which places it in the Controller.
  • B. JavaScript that processes records runs in the View layer and is presentation logic.
  • D. A method that queries is Controller code. The Model is the data it returns, not the method.

Question 85

How does the Lightning Component framework help developers implement solutions faster?

  1. By providing an Agile process with default steps
  2. By providing code review standards and processes
  3. By providing device-awareness for mobile and desktops
  4. By providing change history and version control
Show answer and explanation

Correct answer: C. By providing device-awareness for mobile and desktops

The framework's components are device aware, so the same component renders appropriately on desktop and on mobile. Developers do not build and maintain separate interfaces for each form factor, which is a direct saving in implementation time.

Why the other options are wrong

  • A. The framework is a development technology. It does not prescribe a project methodology.
  • B. Code review standards are a team practice, not a feature of the framework.
  • D. Change history and version control come from source control and the platform's metadata tooling, not from the component framework.

Question 86

Which three data types can be returned from an SOQL statement? (Choose three.)

  1. Boolean
  2. List of sObjects
  3. Single sObject
  4. Integer
  5. String
Show answer and explanation

Correct answer: B, C, D. List of sObjects; Single sObject; Integer

A SOQL statement evaluates to one of three things. It returns a list of sObjects, or a single sObject when the result is assigned to a single variable and exactly one row comes back, or an Integer when the query uses COUNT().

Why the other options are wrong

  • A. There is no Boolean form of a SOQL result. A test for existence is written by checking whether a list is empty or whether a count is greater than zero.
  • E. A SOQL statement does not return a String. Assigning a field from a returned record to a String is a separate step on the sObject.

Question 87

Which Salesforce org has a complete duplicate copy of the production org including data and configuration?

  1. Developer Pro Sandbox
  2. Partial Copy Sandbox
  3. Production
  4. Full Sandbox
Show answer and explanation

Correct answer: D. Full Sandbox

A Full sandbox is the only type that copies the production org in its entirety, both the configuration and all of the records. That makes it the environment used for full regression testing, performance testing and training.

Why the other options are wrong

  • A. A Developer Pro sandbox copies configuration only, with no production records.
  • B. A Partial Copy sandbox copies configuration plus a sample of the data defined by a sandbox template, not the whole data set.
  • C. Production is the original org rather than a copy of it.

Question 88

How should a developer write unit tests for a private method in an Apex class?

  1. Add a test method in the Apex class.
  2. Mark the Apex class as global.
  3. Use the SeeAllData annotation.
  4. Use the TestVisible annotation.
Show answer and explanation

Correct answer: D. Use the TestVisible annotation.

The TestVisible annotation on a private method makes it reachable from test methods while keeping it private to all other code. That lets the unit test call the method directly without weakening the class's encapsulation.

Why the other options are wrong

  • A. Test methods cannot live in a non-test class, and mixing them in would count against the org's Apex limits.
  • B. Marking the class global changes namespace visibility and would still not expose a private member.
  • C. SeeAllData governs access to org records, not to class members.

Question 89

How many levels of child records can be returned in a single SOQL query from one parent object?

  1. 1
  2. 3
  3. 5
  4. 7
Show answer and explanation

Correct answer: A. 1

Parent-to-child and child-to-parent traversal have different limits, and this question asks about the child direction. A single SOQL query can return only one level of child records, so a subquery inside a subquery is not allowed. Traversing upward to parents is the direction that permits five levels.

Why the other options are wrong

  • B. Three is not a limit that applies in either direction.
  • C. Five is the limit for child-to-parent traversal, which is the opposite direction from the one asked about.
  • D. Seven does not correspond to any SOQL relationship limit.

Question 90

What is a capability of the <ltng:require> tag that is used for loading external Javascript libraries in Lightning Component? (Choose three.)

  1. Loading files from Documents.
  2. One-time loading for duplicate scripts.
  3. Specifying loading order.
  4. Loading scripts in parallel.
  5. Loading externally hosted scripts.
Show answer and explanation

Correct answer: B, C, D. One-time loading for duplicate scripts; Specifying loading order; Loading scripts in parallel.

The <ltng:require> tag loads scripts in the order they are listed, loads each script only once even when several components require the same file, and loads scripts in parallel with other resources. Those three behaviours are what the tag provides.

Why the other options are wrong

  • A. Files must be uploaded as static resources. <ltng:require> does not load from Documents.
  • E. Scripts have to be hosted in the org as static resources. Externally hosted scripts are not loaded by this tag.

Question 91

A developer has a Visualforce page and custom controller to save Account records. The developer wants to display any validation rule violations to the user. How can the developer make sure that validation rule violations are displayed?

  1. Add custom controller attributes to display the message.
  2. Use a try/catch with a custom exception class.
  3. Include <apex:messages> on the Visualforce page.
  4. Perform the DML using the Database.upsert() method.
Show answer and explanation

Correct answer: C. Include <apex:messages> on the Visualforce page.

When DML fails a validation rule, the platform adds the error to the page's message collection. Including <apex:messages> renders every message that has been added, so the validation rule violations are shown to the user without the controller doing anything special.

Why the other options are wrong

  • A. Custom attributes mean writing and maintaining code to catch and re-surface errors that the tag already displays.
  • B. A try/catch can trap the DMLException but still has to present it, and a custom exception class adds nothing here.
  • D. Choosing a different DML method changes how failures are reported to the code. It does not display anything on the page.

Question 92

Universal Containers wants a list button to display a Visualforce page that allows users to edit multiple records. Which Visualforce feature supports this requirement?

  1. <apex:listButton> tag
  2. recordSetVar page attribute
  3. custom controller
  4. controller extension
Show answer and explanation

Correct answer: B. recordSetVar page attribute

Setting recordSetVar on the apex:page tag makes the page a list controller, which gives it a collection of selected records and makes the page available as the target of a custom list button. That is what lets users select several records and edit them on one page.

Why the other options are wrong

  • A. There is no apex:listButton tag. The list button is created in Setup on the object.
  • C. A custom controller can hold logic, but the recordSetVar attribute is what makes the page work with a record set and appear as a list button target.
  • D. An extension likewise adds logic without turning the page into a list controller.

Question 93

When a user edits the Postal Code on an Account, a custom Account text field named `Timezone` must be updated based on the values in a PostalCodeToTimezone__c custom object. How should a developer implement this feature?

  1. Build an Account Workflow Rule.
  2. Build an Account Assignment Rule.
  3. Build an Account custom Trigger.
  4. Build an Account Approval Process.
Show answer and explanation

Correct answer: C. Build an Account custom Trigger.

The Timezone value has to be looked up from PostalCodeToTimezone__c, an object that has no relationship to Account. Declarative field updates can only reference the record being saved or a parent it is related to, so retrieving a matching row from an unrelated object and copying its value requires a query, which means Apex.

Why the other options are wrong

  • A. A workflow rule field update cannot query an unrelated object to find the matching postal code row.
  • B. Assignment Rules route Leads and Cases to owners. They do not set arbitrary field values.
  • D. An Approval Process routes a record for approval and does nothing resembling a lookup.

Question 94

A developer needs to display all of the available fields for an object. In which two ways can the developer retrieve the available fields if the variable myObject represents the name of the object? (Choose two.)

  1. Use myObject.sObjectType.getDescribe().fieldSet() to return a set of fields.
  2. Use mySObject.myObject.fields.getMap() to return a map of fields.
  3. Use Schema.describeSObjects(new String[]{myObject})[0].fields.getMap() to return a map of fields.
  4. Use getGlobalDescribe().get(myObject).getDescribe().fields.getMap() to return a map of fields.
Show answer and explanation

Correct answer: C, D. Use Schema.describeSObjects(new String[]{myObject})[0].fields.getMap() to return a map of fields; Use getGlobalDescribe().get(myObject).getDescribe().fields.getMap() to return a map of fields.

When the object name is only known at run time there are two describe routes. Schema.describeSObjects() takes an array of names and the result exposes fields.getMap(). Alternatively getGlobalDescribe() returns a map of all objects keyed by name, and getting the token for the name then calling getDescribe().fields.getMap() returns the same field map. Both return a map of field names to tokens.

Why the other options are wrong

  • A. There is no fieldSet() method on a describe result. Field sets are reached through fieldSets, and they are a curated subset rather than all available fields.
  • B. mySObject.myObject.fields.getMap() is not valid. Dot notation cannot resolve an object whose name is held in a variable, which is exactly why the describe calls exist.

Question 95

A change set deployment from a sandbox to production fails due to a failure in a managed package unit test. The developer spoke with the managed package owner and they determined it is a false positive and can be ignored. What should the developer do to successfully deploy?

  1. Select "Run local tests" to run all tests in the org that are not in the managed package.
  2. Select "Fast Deploy" to run only the tests that are in the change set.
  3. Select "Run local tests" to run only the tests that are in the change set.
  4. Edit the managed package's unit test.
Show answer and explanation

Correct answer: A. Select "Run local tests" to run all tests in the org that are not in the managed package.

Run Local Tests executes every test in the org except those that come from installed managed packages. That skips the managed package test that is failing as a false positive while still running all of the org's own tests, so the deployment can complete without weakening the org's own coverage.

Why the other options are wrong

  • B. There is no Fast Deploy option that limits the run to change set tests. A quick deploy re-uses a previously validated deployment.
  • C. Run Local Tests runs all non-managed tests in the org, not just the ones in the change set. The description is wrong even though the option name is right.
  • D. Code in a managed package is not editable in the subscriber org.

Question 96

A developer must build an application that tracks which Accounts have purchased specific pieces of equipment that are represented as Products. Each Account could purchase many pieces of equipment. How should the developer track that an Account has purchased a piece of equipment?

  1. Use the Asset object
  2. Use a Master-Detail on Product to Account
  3. Use a Custom object
  4. Use a Lookup on Account to Product
Show answer and explanation

Correct answer: A. Use the Asset object

Asset is the standard object that records a specific product a customer has purchased. It has lookups to both Account and Product2, so many assets can hang off one account and each identifies the equipment purchased. Using the standard object brings the related lists and reporting with it.

Why the other options are wrong

  • B. A master-detail from Product to Account would tie each product to a single account and delete products when the account is deleted.
  • C. A custom object would rebuild what Asset already provides.
  • D. A lookup on Account to Product allows only one product per account, which fails the many-purchases requirement.

Question 97

Universal Containers (UC) wants to lower its shipping cost while making the shipping process more efficient. The Distribution Officer advises UC to implement global addresses to allow multiple Accounts to share a default pickup address. The developer is tasked to create the supporting object and relationship for this business requirement and uses the Setup Menu to create a custom object called "Global Address". Which field should the developer add to create the most efficient model that supports the business need?

  1. Add a Master-Detail field on the Global Address object to the Account object.
  2. Add a Master-Detail field on the Account object to the Global Address object.
  3. Add a Lookup field on the Global Address object to the Account object.
  4. Add a Lookup field on the Account object to the Global Address object.
Show answer and explanation

Correct answer: D. Add a Lookup field on the Account object to the Global Address object.

Many Accounts share one default pickup address, so the many side is Account and the one side is Global Address. The relationship field therefore belongs on Account pointing at Global Address, and it is a lookup because the address is optional and an address should survive independently of any single account.

Why the other options are wrong

  • A. This puts the field on the wrong object and makes each address belong to one Account, which prevents sharing.
  • B. A master-detail from Account to Global Address would make Account a detail record, losing its owner and its sharing, and would delete accounts when an address is removed.
  • C. The field is again on the wrong object, so one address could reference only one Account.

Question 98

Which feature allows a developer to create test records for use in test classes?

  1. Documents
  2. WebServiceTests
  3. HttpCalloutMocks
  4. Static Resources
Show answer and explanation

Correct answer: D. Static Resources

A CSV file uploaded as a static resource can be loaded into records inside a test with Test.loadData(), which inserts the rows and returns the created sObjects. That keeps bulk test data out of the Apex source and lets the same data set be reused across tests.

Why the other options are wrong

  • A. Documents store files for general use in the org and are not wired into the test framework.
  • B. There is no WebServiceTests feature. Web service callouts are tested with mocks.
  • C. HttpCalloutMock supplies fake HTTP responses so callouts can be tested. It does not create records.

Question 99

Which three statements are true regarding the @isTest annotation? (Choose three.)

  1. A method annotated @isTest(SeeAllData=true) in a class annotated @isTest(SeeAllData=false) has access to all org data.
  2. A method annotated @isTest(SeeAllData=false) in a class annotated @isTest(SeeAllData=true) has access to all org data.
  3. A class containing test methods counts toward the Apex code limit regardless of any @isTest annotation.
  4. Products and Pricebooks are visible in a test even if a class is annotated @isTest(SeeAllData=false).
  5. Profiles are visible in a test even if a class is annotated @isTest(SeeAllData=false).
Show answer and explanation

Correct answer: A, B, E. A method annotated @isTest(SeeAllData=true) in a class annotated @isTest(SeeAllData=false) has access to all org data; A method annotated @isTest(SeeAllData=false) in a class annotated @isTest(SeeAllData=true) has access to all org data; Profiles are visible in a test even if a class is annotated @isTest(SeeAllData=false).

The SeeAllData setting on an individual method overrides the class setting in both directions, so a method marked true inside a class marked false does see org data, and a method marked false inside a class marked true does see org data as well, because a method cannot narrow a class that has already opened access. Separately, a handful of setup and metadata objects including Profile are always visible to tests regardless of the annotation.

Why the other options are wrong

  • C. Code in classes annotated @isTest does not count against the org's Apex character limit. That is one of the reasons the annotation exists.
  • D. Product2 and Pricebook2 are ordinary data objects and are not visible when SeeAllData is false, which is why Test.getStandardPricebookId() exists.

Question 100

A custom picklist field, Food_Preference__c, exists on a custom object. The picklist contains the following options: `˜Vegan', `˜Kosher', `˜No Preference'. The developer must ensure a value is populated every time a record is created or updated. What is the most efficient way to ensure a value is selected every time a record is saved?

  1. Mark the field as Required on the field definition.
  2. Set "Use the first value in the list as the default value" as True.
  3. Mark the field as Required on the object's page layout.
  4. Set a validation rule to enforce a value is selected.
Show answer and explanation

Correct answer: A. Mark the field as Required on the field definition.

Marking the field Required on the field definition enforces the value everywhere: through the user interface, the API, Apex and data loads. It is a single setting with no formula to maintain, which makes it the most efficient way to guarantee a value on every create and update.

Why the other options are wrong

  • B. A default value only pre-fills the field. A user can still clear it, so a value is not guaranteed.
  • C. Marking a field required on a page layout only enforces it on that layout. Records created through the API, Apex or another layout bypass the rule.
  • D. A validation rule works but is more to build and maintain than simply making the field required.

100 questions in. Want the rest? The first half of the pack, free by email · The full pack

Question 101

A developer wants to import 500 Opportunity records into a sandbox. Why should the developer choose to use Data Loader instead of Data Import Wizard?

  1. Data Loader runs from the developer's browser.
  2. Data Loader automatically relates Opportunities to Accounts.
  3. Data Import Wizard does not support Opportunities.
  4. Data Import Wizard can not import all 500 records.
Show answer and explanation

Correct answer: C. Data Import Wizard does not support Opportunities.

The Data Import Wizard supports only accounts and contacts, leads, solutions, campaign members, person accounts and custom objects. Opportunity is not in that list, so importing Opportunity records requires Data Loader.

Why the other options are wrong

  • A. Data Loader is a desktop client, not a browser tool. The Data Import Wizard is the one that runs in the browser.
  • B. Data Loader does not relate records for you. The AccountId has to be supplied in the file.
  • D. The Data Import Wizard handles up to 50,000 records, so 500 is well within its capacity.

Question 102

A Visualforce page is required for displaying and editing Case records that includes both standard and custom functionality defined in an Apex class called myControllerExtension. The Visualforce page should include which <apex:page> attribute(s) to correctly implement controller functionality?

  1. controller="Case" and extensions="myControllerExtension"
  2. extensions="myControllerExtension"
  3. controller="myControllerExtension"
  4. standardController="Case" and extensions="myControllerExtension"
Show answer and explanation

Correct answer: D. standardController="Case" and extensions="myControllerExtension"

The page needs the standard Case behaviour for displaying and editing the record plus the custom logic in the Apex class, so it uses standardController="Case" to get the built-in functionality and extensions="myControllerExtension" to layer the custom methods on top. Both attributes are required together.

Why the other options are wrong

  • A. controller specifies a custom controller. Case is a standard object, so it belongs in standardController, and naming it in controller would not resolve to a class.
  • B. extensions cannot be used on its own. It always extends a standard or custom controller that must also be declared.
  • C. Naming the extension class as the controller loses all the standard Case display and edit behaviour the page requires.

Question 103

A developer wrote a unit test to confirm that a custom exception works properly in a custom controller, but the test failed due to an exception being thrown. Which step should the developer take to resolve the issue and properly test the exception?

  1. Use try/catch within the unit test to catch the exception.
  2. Use the finally bloc within the unit test to populate the exception.
  3. Use the database methods with all or none set to FALSE.
  4. Use Test.isRunningTest() within the custom controller.
Show answer and explanation

Correct answer: A. Use try/catch within the unit test to catch the exception.

A test that calls code which throws will fail unless the test handles the throw. Wrapping the call in try/catch lets the test catch the custom exception, assert on its type or message, and pass. The catch block is what turns an expected exception into a verified behaviour rather than a test failure.

Why the other options are wrong

  • B. A finally block always runs but does not stop the exception propagating, so the test still fails.
  • C. Setting allOrNone to false suppresses DML failures on individual records. It does not affect an exception thrown by controller logic.
  • D. Branching on Test.isRunningTest() to dodge the exception means the exception path is never actually tested.

Question 104

The operation manager at a construction company uses a custom object called Machinery to manage the usage and maintenance of its cranes and other machinery. The manager wants to be able to assign machinery to different constructions jobs, and track the dates and costs associated with each job. More than one piece of machinery can be assigned to one construction job. What should a developer do to meet these requirements?

  1. Create a lookup field on the Construction Job object to the Machinery object.
  2. Create a lookup field on the Machinery object to the Construction Job object.
  3. Create a junction object with Master-Detail Relationship to both the Machinery object and the Construction Job object.
  4. Create a Master-Detail Lookup on the Machinery object to the Construction Job object.
Show answer and explanation

Correct answer: C. Create a junction object with Master-Detail Relationship to both the Machinery object and the Construction Job object.

A construction job can have several pieces of machinery and a piece of machinery is assigned to several jobs over time, which is a many-to-many relationship. The platform models that with a junction object holding master-detail relationships to both Machinery and Construction Job. The junction record is also the natural place for the dates and costs of each assignment, which is what the manager wants to track.

Why the other options are wrong

  • A. A lookup on Construction Job to Machinery allows only one machine per job, which contradicts the requirement.
  • B. A lookup on Machinery to Construction Job ties a machine to a single job and loses the history of earlier assignments along with their dates and costs.
  • D. A single master-detail from Machinery to Construction Job is still one-to-many and cannot record a machine on more than one job.

That was 104 of 439.

The full Salesforce Platform Developer pack has all 439 questions, each with the answer, the explanation and why the other options are wrong, plus a questions-only copy for timed runs. US$39, paid once, with free monthly updates and a pass-or-your-money-back guarantee.

Get the full pack

Not ready yet? Get the first 219 free as one PDF by email. Get the Half Pack →