readyforhires

Salesforce Development test (Intermediate)

30 questions · 35 minutes · Free

Apex, SOQL, Lightning Web Components, the data model, flows and integration.

Take the Salesforce Development test

What it covers

Interview format

Sample questions

5 sample questions from the Salesforce Development test, with the answers. Samples are taken out of the live test, so you will not meet these when you sit it.

  1. Which of the following is a best practice for writing bulk-safe Apex?

    1. Use triggers to perform unrelated DML operations on other objects.
    2. Use one trigger per object delegating to a handler class.
    3. Use SOQL or DML inside loops to process individual records.
    4. Use multiple triggers on the same object to handle different logic.

    Answer: B. Use one trigger per object delegating to a handler class.

    To ensure bulk-safe Apex, it's important to use one trigger per object and delegate logic to a handler class. This approach helps avoid hitting governor limits and ensures efficient processing of large data volumes. Other options, such as using SOQL or DML inside loops or using triggers for unrelated logic, are not bulk-safe practices.

  2. Which of the following is the correct approach for storing key-value pairs where the key is unique and allows for efficient lookups based on the key in Apex?

    1. Use a Map to store key-value pairs where the key is unique and allows for efficient lookups based on the key.
    2. Use a Queue to store key-value pairs where the key is unique and allows for efficient lookups based on the key.
    3. Use a List to store key-value pairs where the key is unique and allows for efficient lookups based on the key.
    4. Use a Set to store key-value pairs where the key is unique and allows for efficient lookups based on the key.

    Answer: A. Use a Map to store key-value pairs where the key is unique and allows for efficient lookups based on the key.

    A Map is the appropriate choice when you need to store key-value pairs and perform lookups based on the key. Lists are better suited for ordered collections where the index is used for access. Sets are ideal for storing unique elements without any specific order. Queues are used for managing elements in a first-in, first-out (FIFO) order, typically for processing tasks.

  3. You are developing an Apex class that needs to dynamically construct a SOQL query based on user input. How should you safely handle potential injection risks from the user input?

    1. Directly concatenate user input into the SOQL query string
    2. Use `String.escapeSingleQuotes` without `Database.query` for dynamic SOQL
    3. Use `Database.query` with `String.escapeSingleQuotes` to prevent injection
    4. Use `String.escape` to escape user input for SOQL queries

    Answer: C. Use `Database.query` with `String.escapeSingleQuotes` to prevent injection

    When constructing dynamic SOQL queries in Apex, it is essential to use `Database.query` with `String.escapeSingleQuotes` to properly escape user input and prevent SOQL injection attacks. Using `String.escapeSingleQuotes` ensures that any special characters in the input are safely escaped, making the query secure. Using `String.escape` is not the correct method for escaping SOQL queries, and directly concatenating user input into the query can lead to injection vulnerabilities. Apex does not support using `String.escape` for this purpose.

  4. Which of the following best describes the performance characteristics of Apex maps and sets?

    1. Apex maps and sets are optimized for fast lookups and insertions, making them ideal for bulk operations.
    2. Apex maps and sets use linked lists for efficient insertion and deletion operations.
    3. Apex maps and sets are not optimized for performance in bulk operations.
    4. Apex maps and sets are implemented as arrays for quick access to elements.

    Answer: A. Apex maps and sets are optimized for fast lookups and insertions, making them ideal for bulk operations.

    Apex maps and sets are optimized for fast lookups and insertions, making them ideal for bulk operations. This is because maps use hashing for efficient key-value pair lookups, and sets use hashing for efficient membership checks. These optimizations make them perform better than lists in scenarios where frequent lookups or insertions are required, especially in bulk operations. The other options are incorrect because they do not accurately describe the internal performance characteristics of Apex maps and sets.

  5. What happens when a child Lightning Web Component dispatches a custom event with data and the parent component listens for it?

    1. The child component automatically updates its UI based on the event data.
    2. The event is ignored by the parent component if no handler is defined.
    3. The parent component receives the event and can access its data via the event.detail property.
    4. The event data is stored in the component's state and can be accessed later.

    Answer: C. The parent component receives the event and can access its data via the event.detail property.

    In Lightning Web Components, when a child component dispatches a custom event using `this.dispatchEvent(new CustomEvent('eventname', { detail: data }))`, the parent component listens for the event using `@wire` or `addEventListener`. The parent component can access the data passed in the event using `event.detail`.

Frequently asked questions

How many questions are in the Salesforce Development test?
30 questions (18 multiple choice, 9 multi-answer, 3 predict-the-output), with 35 minutes to answer them.
What does the Salesforce Development test cover?
Apex programming, SOQL and SOSL, Lightning Web Components, Salesforce data model and security, Flows and automation.
Is the Salesforce Development test free?
Yes. It is free to take with a readyforhires account.
What level is the Salesforce Development test?
Intermediate, in Enterprise apps.

More Enterprise apps tests

All practice tests · All Enterprise apps tests

Last updated