Which approach is recommended to ensure test data is cleaned up?
This ensures no data side effects.
Why this answer
Salesforce automatically rolls back all data created in a test method after completion.
493 questions total · 7pages · All types, answers revealed
Which approach is recommended to ensure test data is cleaned up?
This ensures no data side effects.
Why this answer
Salesforce automatically rolls back all data created in a test method after completion.
Which THREE operations will cause an immediate transaction rollback or DML failure when utilizing standard DML statements in Apex? Choose 3 answers.
Validation rule failures cause the entire standard DML transaction to roll back.
Why this answer
Uncaught exceptions, hit governor limits, or triggering record-level validation errors via addError() will fail the transaction or records.
A developer needs to navigate to a record detail page from a Lightning Web Component. Which service should be used?
Provides navigation service methods.
Why this answer
NavigationMixin from lightning/navigation is used for navigation in LWCs.
Which Apex data type is best suited for storing monetary amounts with high precision?
Decimal is precise and is the standard type used for currency fields in Salesforce.
Why this answer
The Decimal data type is used for currency and precise numerical calculations in Apex.
You need to inspect the heap size during the execution of a long-running batch job. Which debug log category should you monitor?
Profiling is specifically designed for monitoring resource consumption.
Why this answer
The Profiling category logs governor limit usage, including heap size and CPU time.
What is the correct file extension for an Apex class created in Salesforce DX?
Apex classes use the .cls extension.
Why this answer
Apex class files use the .cls extension, accompanied by a .cls-meta.xml metadata file.
A developer wants to conditionally display an HTML element in a Lightning Web Component template based on a boolean property named 'isVisible'. Which directive should be used?
Conditionally renders DOM elements based on a boolean expression.
Why this answer
lwc:if is the modern conditional directive in LWC.
Which trigger context variable is available exclusively in before insert, before update, and before delete triggers to modify field values?
Modifications to sObjects in Trigger.new within before triggers are automatically saved to the database without needing an explicit DML statement.
Why this answer
Trigger.new contains sObjects that can be modified in-flight during before insert and before update triggers.
Which TWO of the following are true about the 'Debug Log' settings in the Setup menu?
Trace flags must be defined with an expiration window.
Why this answer
Logs can be set for users, and the duration of those log traces is limited.
A developer is writing a test for a method that performs a callout. How must the callout be handled?
Standard practice for testing callouts.
Why this answer
Callouts must be mocked using HttpCalloutMock to avoid external network dependencies.
A developer wants to retrieve up to 5 recently viewed records of any object type using SOSL. Which SOSL clause specifies the maximum number of records to return?
The LIMIT clause restricts the number of rows returned by a SOSL query.
Why this answer
SOSL search results can be limited using the LIMIT clause at the end of the query statement.
Which THREE statements are true regarding Future methods in Apex? Choose 3 options.
The @future annotation is mandatory to designate a method for asynchronous execution.
Why this answer
Future methods run asynchronously, must be annotated with @future, and cannot accept sObjects as arguments because sObject records can change between the time the method is called and when it executes.
During the execution of a trigger, an unhandled exception occurs in an after update trigger. What happens to the database transaction?
Apex transactions are atomic; any unhandled exception causes a complete rollback.
Why this answer
An unhandled exception in any trigger causes the entire database transaction to roll back entirely.
A developer writes a SOQL query to aggregate total opportunity amounts grouped by stage name. Which SOQL clause is required?
GROUP BY is required when aggregating data by specific fields.
Why this answer
Aggregate queries in SOQL require the GROUP BY clause when using functions like SUM(), COUNT(), or AVG().
Which TWO of the following are limitations when deploying using the Metadata API?
A manifest is required for Metadata API.
Why this answer
Metadata API deployments require a manifest file and are subject to the same validation rules as the org.
Which TWO data types can be used as keys in an Apex Map? Choose 2 answers.
IDs are frequently used as map keys for sObject mapping.
Why this answer
Primitive data types like String, ID, and Integer can be used as map keys in Apex.
A developer needs to write a unit test to verify that a trigger correctly inserts related Task records when a custom object record is created. Which annotation should the developer place on the test class method to ensure it runs correctly and can access existing org data if needed?
The @isTest annotation is required on test classes and test methods to define them for execution.
Why this answer
The @isTest annotation identifies a method or class as containing unit tests. Using @isTest(SeeAllData=true) is sometimes required when legacy data must be accessed, though best practice is to create test data locally.
When deploying metadata from a sandbox to production using Change Sets, what is the first requirement?
Deployment connections are mandatory for moving Change Sets between environments.
Why this answer
A Deployment Connection must be established between the two organizations before a Change Set can be sent.
A developer is writing an Apex trigger and needs to optimize performance and prevent governor limit violations. Which TWO practices should the developer follow? (Choose two.)
Trigger context variables hold collections of sObjects, allowing batch processing of records.
Why this answer
Triggers must be bulkified to handle collections of records and queries/DML operations must be kept outside loops.
A developer is designing a Lightning Web Component that needs to communicate with another component located anywhere in the application hierarchy, including unrelated components. Which TWO mechanisms are valid and appropriate for this requirement? Choose 2 answers.
Correct. A custom pub/sub utility using EventTarget or custom events allows decoupled components to communicate.
Why this answer
Lightning Message Service (LMS) and custom PubSub patterns built on top of standard browser events or custom event dispatchers are suited for communication across unrelated components.
Which trigger context variable should be used to check if a trigger is running in a before-insert context?
These variables correctly identify the context.
Why this answer
Trigger.isBefore and Trigger.isInsert are standard context variables.
A developer needs to configure a Lightning Web Component to be available for use on Lightning Record Pages. Which configuration entry must be present in the component's metadata file (.js-meta.xml)?
Enables the component for record pages.
Why this answer
lightning__RecordPage target enables a component to be placed on record pages.
A developer needs to ensure that a custom Apex controller safely checks whether the current user has read access to the 'Salary__c' field on the 'Employee__c' object before displaying it in a Lightning Web Component. Which method should the developer use?
The isAccessible() method on the field describe result returns true if the current user has read access to the field.
Why this answer
The Security class and sObjectDescribe methods provide mechanisms to check CRUD and FLS in Apex before querying or displaying data.
A developer wrote a batch job that encounters unhandled exceptions on specific records. To ensure that processing of other records continues despite errors in a chunk, what parameter should be configured in the start method or execution?
Setting allOrNone to false during DML operations in batch allows partial success and failure logging.
Why this answer
Using Database.executeBatch with the default scope or handling exceptions within the execute method using try/catch ensures successful records are committed while failed ones can be logged.
What is the maximum number of SOQL queries that can be issued in a single synchronous Apex transaction?
Salesforce permits a maximum of 100 SOQL queries in a synchronous transaction.
Why this answer
The synchronous governor limit for SOQL queries is 100.
Which THREE items are valid considerations when designing Batch Apex?
This is required for the execute method.
Why this answer
Batch Apex requires start, execute, and finish methods and is subject to specific heap and query limits.
A developer is writing a unit test that executes under a specific user context to verify sharing rules. Which method should the developer use to specify the user for the subsequent test operations?
System.runAs allows block-level execution under a specified User instance to test sharing behavior.
Why this answer
System.runAs() enables developers to run test methods under a specific user context to verify record-level security and sharing rules.
Which tag is used in Visualforce to include custom CSS stylesheets?
Includes a stylesheet in the page.
Why this answer
<apex:stylesheet> is used to include external CSS files in Visualforce.
A developer wants to define a constant value in an Apex class that can be accessed globally without instantiating the class. Which combination of keywords should be used?
'static' associates the variable with the class, and 'final' ensures it acts as a constant once initialized.
Why this answer
Constants in Apex are defined using the 'static' and 'final' keywords to ensure they belong to the class and cannot be modified.
A developer has written a Before Insert trigger on the Contact object that needs to validate user input and potentially prevent the record from saving. Which method on the Trigger context or record instance should the developer use to flag an error?
addError() prevents the DML operation and displays an error message on the record or page.
Why this answer
To prevent a record from saving in a before trigger, the developer must use the addError() method on the sObject record instance.
A developer needs to format a currency value according to the user's locale in a Lightning Web Component HTML template. Which base component should be used?
Supports currency formatting based on user locale.
Why this answer
lightning-formatted-number with format-style="currency" or lightning-formatted-text is used for formatting.
What happens if a developer creates a test method that does not contain any assertions?
Tests require assertions to be meaningful.
Why this answer
The test will pass as long as the code runs without error, but it is not a valid test.
A developer needs to create a custom tab for a Lightning Web Component so it can be navigated to from the App Launcher. What type of custom tab must be created?
Correct because Lightning Component Tabs expose LWC to the App Launcher and navigation menus.
Why this answer
Lightning component tabs allow Lightning Web Components and Aura components to be exposed as tabs.
A developer is working with a Lightning Web Component and needs to access a child component's public method from the parent component. How is this achieved?
Public child methods are callable directly from the parent via the component reference.
Why this answer
Public methods on child components must be decorated with @api and invoked via this.template.querySelector().methodName().
What is the primary benefit of using a Flow over an Apex trigger for simple field updates?
Declarative tools reduce technical debt and maintenance.
Why this answer
Flows are declarative, easier to maintain, and require no code, making them faster to deploy.
Which TWO statements are true regarding the behavior of Apex triggers and context variables? Choose 2 answers.
Trigger.old holds pre-update and pre-delete record states.
Why this answer
Trigger.new is available on insert, update, and undelete. Trigger.old is available on update and delete.
Which of the following is a limitation of Change Sets?
Change Sets require a deployment connection between the source and target orgs.
Why this answer
Change Sets are strictly one-way and cannot be used to deploy changes from production back to a sandbox.
Which THREE collections are available in Apex? (Choose three.)
Set is a fundamental collection type in Apex.
Why this answer
Apex provides three built-in collection types: List, Set, and Map.
What is a key advantage of using Queueable Apex over future methods?
Unlike future methods which only accept primitives, Queueable Apex accepts complex sObjects and collections.
Why this answer
Queueable Apex supports non-primitive data types and job chaining.
A developer is styling a Lightning Web Component using the Salesforce Lightning Design System (SLDS). To ensure the component adheres to the standard styling guidelines for spacing, what should the developer use?
Correct because SLDS utility classes provide consistent, standardized spacing.
Why this answer
SLDS provides predefined design tokens and CSS utility classes (such asslds-m-around_medium) for consistent spacing.
A developer needs to execute long-running computations that require complex chaining and the ability to pass non-primitive data types to the job. Which asynchronous feature should the developer implement?
Queueable Apex supports non-primitive types and provides job chaining via System.enqueueJob.
Why this answer
Queueable Apex supports the Database.AllowsCallouts interface, allows chaining of jobs, and accepts member variables of non-primitive types such as custom objects.
A developer needs to execute logic after a record is inserted into the database but before the database commits the transaction. Which trigger event is most appropriate?
after insert is used for post-processing and accessing the record ID.
Why this answer
The after insert trigger event executes after the record is saved to the database but before the final commit.
A developer has created a custom Aura component that needs to be embedded within a Lightning Web Component. What is the correct rule regarding component composition between Aura and LWC?
Correct because Aura components support embedding Lightning Web Components.
Why this answer
An LWC can contain an Aura component, provided the Aura component is wrapped or referenced according to framework rules, but Aura cannot directly contain arbitrary LWC without proper wrapping. Wait, actually, LWC can contain Aura components? No, LWC can contain Aura components ONLY if they are wrapped, but more precisely, Aura components CAN contain LWC. Let's verify: Aura can contain LWC, but LWC cannot contain Aura directly.
Let's adjust the options.
Which TWO features are characteristic of Flow Builder compared to Apex triggers? (Choose two.)
Flow Builder is a visual drag-and-drop tool for declarative automation.
Why this answer
Flow Builder is declarative, provides visual debugging, and allows point-and-click creation.
A developer is writing a test method that performs a callout to an external REST service. Which interface must the developer implement to provide mock responses during the unit test execution?
HttpCalloutMock must be implemented to return fake responses since actual callouts are not permitted in test methods.
Why this answer
HttpCalloutMock is the interface implemented to supply a mock HTTP response during test context when callouts are made.
Which tool provides a declarative alternative to Apex triggers for creating records when another record is created?
Record-triggered flows can create and update related records declaratively.
Why this answer
Record-triggered flows in Flow Builder allow declarative creation of related records.
A developer needs to call an external web service from an Apex trigger. Why must this be done asynchronously?
Salesforce prevents synchronous callouts in triggers to ensure transaction integrity.
Why this answer
DML operations and external callouts cannot be mixed in the same transaction; callouts require asynchronous processing.
A developer needs to see how much memory a specific Apex method is consuming. Which log category should be adjusted?
Profiling provides memory and resource usage data.
Why this answer
The Profiling category provides detailed information on resource consumption.
Which lifecycle hook in a Lightning Web Component runs after every render of the component?
Correct because renderedCallback runs after every render cycle.
Why this answer
renderedCallback() is called after every render of the component, useful for post-rendering DOM manipulation.
Which THREE statements are accurate regarding asynchronous Apex governor limits and best practices? (Choose three.)
Correct. Asynchronous transactions generally receive higher governor limits.
Why this answer
Asynchronous Apex provides higher governor limits, but developers must avoid chaining loops and respect daily limits.
A developer wants to log information specifically when a condition is met. Which method is most appropriate?
Correct method for adding logs.
Why this answer
System.debug() is used to add custom messages to the debug log.
Which collection method is used to add all elements from one Set into another Set in Apex?
addAll() adds all elements of a collection to the target set.
Why this answer
The addAll() method is available on Set, List, and Map collections to add multiple elements at once.
An architect is designing an automation solution and wants to decide between a Record-Triggered Flow and an Apex Trigger. Which scenario heavily favors choosing an Apex Trigger?
Apex natively handles complex callout chaining and exception handling better than declarative flows.
Why this answer
Complex integrations, callouts, and heavy algorithmic processing across multiple disparate objects often necessitate Apex triggers over declarative flows.
An Apex trigger needs to prevent duplicate records from being inserted based on a custom external ID field. Which approach should the developer take to optimize query performance and respect governor limits?
This is fully bulkified and avoids governor limit violations.
Why this answer
Collecting field values into a Set, querying existing records matching that Set in a single query outside of loops, and comparing in memory is the bulkified approach.
Which THREE factors can cause an Apex CPU time limit exception in a synchronous transaction? Choose 3 answers.
Nested loops with high iteration counts rapidly consume CPU time.
Why this answer
Heavy loops, complex triggers, inefficient nested queries or collections processing, and excessive regex or string manipulations contribute to CPU time exhaustion.
A developer needs to process 2 million records asynchronously, performing complex calculations and updating parent records in batches of 2,000. Which feature should the developer implement?
Batch Apex allows processing of millions of records using Database.Batchable and custom batch sizes up to 2,000.
Why this answer
Batch Apex is designed for processing large datasets in chunks asynchronously.
A developer is configuring a Lightning Web Component metadata file to allow the component to be placed on a FlexPage. Which tag defines the configuration regions or design properties?
Correct because design files define attributes exposed in the Lightning App Builder.
Why this answer
The <masterLabel> and <targets> are used, but design properties are defined in a separate design file (.design). Wait, configuration regions for App Builder properties are defined in the .design file for Aura, but in LWC design properties are also in a .design file. Let's frame the question around design files.
A developer needs to invoke a long-running external web service callout from an existing scheduled Apex job that implements the Schedulable interface. What is the correct approach to implement this callout?
Correct. Enqueueing a Queueable job that implements Database.AllowsCallouts allows callouts to be made successfully from scheduled contexts.
Why this answer
Schedulable Apex cannot directly make synchronous callouts because the thread must wait for the network response. Developers must chain a Queueable class that implements Database.AllowsCallouts.
A developer needs to write a Batch Apex class that processes records and ensures atomicity per batch chunk. Which TWO statements are true regarding Database.Batchable execution and error handling? (Choose TWO.)
Using partial DML allows successful records in the chunk to commit while failing ones are logged.
Why this answer
Using Database.insert(records, false) allows partial success within a batch chunk, and state can be maintained across chunks if Database.Stateful is used.
A developer is analyzing the Salesforce order of execution for a record update. Which TWO events occur AFTER custom validation rules are evaluated? (Choose TWO.)
Assignment and escalation rules run after validation and before after-triggers.
Why this answer
After triggers and assignment rules occur after custom validation rules in the save order of execution.
A developer is creating a Lightning Web Component that needs to display a list of Accounts. The developer wants to fetch the data imperatively when a user clicks a button rather than automatically via a wire adapter. What is the correct approach?
Correct because imperative Apex is called as a function returning a promise inside an event handler.
Why this answer
Imperative Apex calls are invoked as standard JavaScript promises, typically triggered by an event handler such as a button click.
A developer needs to assign a default value to a custom picklist field via Apex when creating a Lead record. What data type should be assigned to the picklist field in Apex?
Picklist values are represented as String types in Apex sObject assignments.
Why this answer
Picklist fields in Salesforce are represented as Strings in Apex when assigned or retrieved via sObjects.
Which THREE limitations apply when writing Future methods in Apex? (Choose three.)
Future methods only accept primitive data types or collections of primitives.
Why this answer
Future methods cannot accept sObjects, cannot be tracked easily with job IDs, and cannot be called from other future methods.
Which THREE tools or contexts can be used to execute Anonymous Apex code? Choose 3 options.
SF CLI supports running anonymous apex scripts.
Why this answer
Anonymous Apex can be executed via the Developer Console, Salesforce Extensions for VS Code, and Salesforce CLI (sf apex run).
A developer is writing an Apex test class and needs to reset governor limits before executing a block of asynchronous code testing. Which method should the developer use?
Test.startTest() marks the point when test execution begins and resets governor limits.
Why this answer
Test.startTest() and Test.stopTest() bracket the test section, resetting governor limits for the execution block within them and forcing any asynchronous calls to run synchronously.
A developer needs to access the old values of a record in an Apex trigger. Which collection provides this?
Trigger.old holds the previous versions of the records.
Why this answer
Trigger.old contains the list of records before the update or deletion.
A developer wants to style a Lightning Web Component using the Salesforce Lightning Design System (SLDS). What is the recommended way to include SLDS styling?
SLDS classes are available by default in Salesforce environments.
Why this answer
LWC natively incorporates SLDS styling when using standard base components, but custom styling should use standard SLDS CSS utility classes.
A developer writes an Apex trigger that performs a SOQL query inside a standard for-loop processing Trigger.new. Which governor limit is most likely to be exceeded?
Placing a SOQL query inside a loop causes a query to run for every record in the batch, hitting the 100 SOQL query limit.
Why this answer
Querying inside loops easily exhausts the total SOQL queries issued per transaction limit of 100.
Which TWO statements about Apex variables and initialization are true? Choose 2 options.
Apex is a strongly typed language requiring explicit data type declarations.
Why this answer
Unassigned primitive variables default to null, and variables must be declared with a type before use.
An asynchronous @future method is called from within an Apex test method. When are the statements inside the @future method actually executed during the test run?
Test.stopTest collects all asynchronous processes and runs them synchronously before resuming test execution.
Why this answer
Asynchronous methods called in tests are queued and executed synchronously after the Test.stopTest() statement.
A developer is troubleshooting a complex set of triggers and wants to restrict the amount of debug log data captured for a specific integration user. Which THREE actions can the developer take to manage debug logs effectively? (Choose three.)
Debug levels define the granularity of logs recorded per category.
Why this answer
Trace flags control log levels and duration for users, classes, or triggers. Log categories allow filtering verbosity.
What is the maximum number of debug logs that can be stored per user?
Based on aggregate size.
Why this answer
There is a limit (typically 50MB per user, but logs are replaced).
A developer needs to store a collection of Account IDs where duplicates are automatically prevented and lookups are extremely fast. Which collection type should the developer use?
Sets inherently prevent duplicate entries and offer optimal performance for membership checks.
Why this answer
Sets in Apex store unique elements and provide very fast lookups by value using methods like contains().
Which THREE operations can cause an automatic roll back of an entire Apex transaction? Choose 3 options.
Governor limit violations immediately terminate and roll back transactions.
Why this answer
Unhandled exceptions, unhandled DML errors with allOrNone=true, and governor limit violations roll back the transaction.
A developer needs to verify that a trigger correctly handles bulk data, specifically 250 records. What is the most effective approach?
Inserting a collection of records is the standard way to test bulk DML operations.
Why this answer
Testing with a collection of records validates bulkification and prevents governor limit exceptions.
Practice SALESFORCE-PD1 by domain
Target a specific domain to shore up weak areas.
See all domains with question counts →