PD1 Flashcards

1
Q

Which statement results in an Apex compiler error?
A. Map<Id,Lead> lmap = new Map<Id,Lead>([Select ID from Lead Limit 8]);
B. Date d1 = Date.Today(), d2 = Date.ValueOf(‘2018-01-01’);
C. Integer a=5, b=6, c, d = 7;
D. List<string> s = List<string>{'a','b','c');</string></string>

A

D. List<string> s = List<string>{'a','b','c');
This contains a syntax error. The opening brace { is correct, but the closing bracket should also be a brace } instead of a parenthesis ). The correct statement should be:
List<string> s = new List<string>{'a','b','c'};</string></string></string></string>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are two benefits of the Lightning Component framework? (Choose two.)
A. It simplifies complexity when building pages, but not applications.
B. It provides an event-driven architecture for better decoupling between components.
C. It promotes faster development using out-of-box components that are suitable for desktop and mobile devices.
D. It allows faster PDF generation with Lightning components.

A

The Lightning Component framework is a UI framework for developing dynamic web apps for mobile and desktop devices with no JavaScript required on the client side. Here are the benefits based on the given options:

A. It simplifies complexity when building pages, but not applications.
This statement is partly misleading. While Lightning does simplify the process of building pages, it’s also designed for application development. So, this isn’t a clear benefit statement.

B. It provides an event-driven architecture for better decoupling between components.
Correct. The event-driven architecture of the Lightning Component framework allows components to be more decoupled, making them more reusable and modular.

C. It promotes faster development using out-of-box components that are suitable for desktop and mobile devices.
Correct. The Lightning Component framework comes with a series of out-of-the-box components that can be used to accelerate development. These components are also responsive, making them suitable for both desktop and mobile devices.

D. It allows faster PDF generation with Lightning components.
This statement is not a core benefit of the Lightning Component framework. While you can create components that interact with services or tools that generate PDFs, the framework itself doesn’t inherently make PDF generation faster.

So, the two benefits of the Lightning Component framework from the given options are:
B. It provides an event-driven architecture for better decoupling between components.
C. It promotes faster development using out-of-box components that are suitable for desktop and mobile devices.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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?
A. Use the first three characters of the sObject ID to determine the sObject type.
B. Use the getSObjectType method on each generic sObject to retrieve the sObject token. Most Voted
C. Use the getSObjectName method on the sObject class to get the sObject name.
D. Use a try-catch construct to cast the sObject into one of the three sObject types.

A

Out of the given options, the correct way to determine the type of a generic sObject is:

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

When you call the getSObjectType method on a generic sObject, it returns the sObject token which can be used to determine its type. You can then convert that token to a string to get the name of the sObject type.

For instance:

apex
Copy code
sObject sobj = new Account();
Schema.SObjectType sobjType = sobj.getSObjectType();
String objectName = sobjType.getDescribe().getName();
Option A is incorrect because the first three characters of the sObject ID correspond to the key prefix, and while they do determine the type, it’s not a recommended or direct way to get the sObject type.

Option C is incorrect as there isn’t a method called getSObjectName on the sObject class.

Option D is not a recommended approach because using try-catch to determine types (rather than handle actual exceptions) is not efficient or clear. It also doesn’t scale well if you have more than a few object types.

So, the best answer is:
B. Use the getSObjectType method on each generic sObject to retrieve the sObject token.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What should a developer use to implement an automatic Approval Process submission for Cases?
A. An Assignment Rule
B. Scheduled Apex
C. Process Builder
D. A Workflow Rule

A

To implement an automatic Approval Process submission for Cases, a developer should use:

C. Process Builder

With Process Builder, you can define criteria and actions. When the criteria are met, the actions are executed. One of the actions you can define is submitting a record for approval, which makes it suitable for automating Approval Process submission for Cases.

Option A, An Assignment Rule, is used for automatically assigning incoming cases (or leads) to particular users or queues based on criteria.

Option B, Scheduled Apex, could technically be used for this purpose, but it’s a more complex solution than necessary for this task.

Option D, A Workflow Rule, can automate standard internal procedures, but it doesn’t have the capability to submit records for approval.

Thus, the best choice is:
C. Process Builder.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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?
A. Create a trigger on the Quote object that queries the Quantity field on discounted Quote Line Items.
B. Create a Workflow Rule on the Quote Line Item object that updates a field on the parent Quote when the item is discounted.
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.
D. 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.

A

Among the given options, the best way to meet the requirement is by using a roll-up summary field if the objects have a master-detail relationship.

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.

However, it’s important to note that for the roll-up summary field to be available, the relationship between the Quote and Quote Line Item objects must be a master-detail relationship. Salesforce natively supports roll-up summary fields on master-detail relationships, allowing the aggregation of child record data (in this case, the Quote Line Items) into the parent record (in this case, the Quote).

Option A: A trigger could accomplish the task, but using native features like roll-up summary fields is preferred over writing code whenever possible due to easier maintenance, better transparency, and less complexity.

Option B: Workflow rules are used for field updates, tasks, email alerts, and outbound messages. They are not ideal for this requirement, especially since roll-up operations aren’t directly supported by workflows.

Option D: Formula fields are for real-time calculations and cannot iterate over child records like a roll-up would, so they can’t be used to aggregate data from child records in the manner described in the requirement.

Thus, the best choice is:
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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?
A. Use Test.getStandardPricebookId() to get the standard price book ID. Most Voted
B. Use @IsTest(SeeAllData=true) and delete the existing standard price book.
C. Use Test.loadData() and a Static Resource to load a standard price book.
D. Use @TestVisible to allow the test method to see the standard price book.

A

Out of the given options, the correct way to access the standard price book in a test class in Salesforce is:

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

The method Test.getStandardPricebookId() is provided specifically to allow developers to get the ID of the standard price book in a test context without requiring access to all data.

Option B is not advisable. Using @IsTest(SeeAllData=true) means the test method will see all the data in the org, which can lead to unpredictable test results and isn’t a best practice. Furthermore, you shouldn’t delete the existing standard price book.

Option C isn’t correct for this context. While Test.loadData() is useful for loading test data from static resources, you don’t typically need to use it for accessing standard price books.

Option D isn’t applicable in this context. @TestVisible is an annotation that makes private class members visible to test methods. It doesn’t have relevance to accessing standard price books.

So, the best choice is:
A. Use Test.getStandardPricebookId() to get the standard price book ID.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which two Apex data types can be used to reference a Salesforce record ID dynamically? (Choose two.)
A. ENUM
B. sObject Most Voted
C. External ID
D. String Most Voted

A

To reference a Salesforce record ID dynamically, the following two Apex data types can be used:

B. sObject: In Apex, an sObject can be any object (standard or custom). When you query a record, it is returned as an sObject type, and you can get its ID dynamically.

D. String: A Salesforce record ID is represented as a 15-character or 18-character string. Therefore, you can use a string data type to hold or reference a Salesforce record ID.

Option A (ENUM) is not relevant for referencing Salesforce record IDs.

Option C (External ID) is a user-defined field that allows you to store a unique identifier for a record from another system. While it can help in upsert operations, the external ID itself is not a data type to reference a Salesforce record ID.

So, the correct answers are:
B. sObject
D. String

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Where can a developer identify the time taken by each process in a transaction using Developer Console log inspector?
A. Performance Tree tab under Stack Tree panel
B. Execution Tree tab under Stack Tree panel
C. Timeline tab under Execution Overview panel
D. Save Order tab under Execution Overview panel

A

In the Developer Console’s log inspector, the time taken by each process in a transaction can be identified in the:

C. Timeline tab under Execution Overview panel

The Timeline tab provides a graphical representation of the time taken by each process in a transaction, making it easy to identify and analyze performance bottlenecks.

The other options:

A. Performance Tree tab: This is not an actual tab in the Developer Console.
B. Execution Tree tab: This is not an actual tab in the Developer Console.
D. Save Order tab: This is not related to identifying the time taken by each process.

Thus, the correct answer is:
C. Timeline tab under Execution Overview panel.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which two platform features align to the Controller portion of MVC architecture? (Choose two.)
A. Process Builder actions Most Voted
B. Workflow rules Most Voted
C. Standard objects
D. Date fields

A

The MVC (Model-View-Controller) architecture divides software development into three interconnected components:

Model: Represents the data structures and business logic.
View: Represents the UI of the application.
Controller: Manages the user input and updates the Model and View accordingly.
Given the options and thinking about Salesforce:

A. Process Builder actions: This can be thought of as a Controller because it can take user input or detect changes in records and then execute actions (like changing data or calling other processes).

B. Workflow rules: Similar to Process Builder, workflow rules can be seen as a Controller. They evaluate criteria and then take actions based on changes or inputs.

C. Standard objects: These are more aligned with the Model as they represent data structures and relationships in Salesforce.

D. Date fields: These are part of the Model since they represent a data structure or attribute of an object.

So, the two platform features that align to the Controller portion of MVC architecture are:
A. Process Builder actions
B. Workflow rules

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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.)
A. Developer Sandbox
B. Full Sandbox Most Voted
C. Developer Edition
D. Partial Sandbox Most Voted
E. Developer Pro Sandbox

A

Given the requirements provided, we should choose the environments based on their storage capacities and functionalities:

A. Developer Sandbox: This type of sandbox includes a copy of your production organization’s configuration (metadata) but no production data. It only provides a limited amount of storage (e.g., 200 MB for file and data storage combined), which is not sufficient for the 2 GB of data needed for testing.

B. Full Sandbox: A Full Sandbox copies all of your production organization’s data and metadata. It has the same storage limit as your production environment, so it can handle the 2 GB of test data. This is one of the correct choices.

C. Developer Edition: Developer Edition orgs are stand-alone environments and not sandboxes. They come with a very limited amount of storage (e.g., 5 MB for data and 20 MB for files), which is far below the required 2 GB for testing.

D. Partial Sandbox: Partial Sandboxes include your production organization’s metadata and a sample of your production data, defined by a sandbox template. The storage limit for a Partial Sandbox is 5 GB for data and 5 GB for files, which can accommodate the 2 GB of test data required. This is another correct choice.

E. Developer Pro Sandbox: A Developer Pro Sandbox includes a copy of your production organization’s configuration (metadata) but no production data. It provides more storage than a regular Developer Sandbox (e.g., 1 GB for data and files combined), but this might still be insufficient for the 2 GB of data needed for testing.

The two environments that meet the requirements for testing are:
B. Full Sandbox
D. Partial Sandbox

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

A developer working on a time management application wants to make total hours for each timecard available to application users. A timecard entry has a Master-
Detail relationship to a timecard.
Which approach should the developer use to accomplish this declaratively?
A. A Visualforce page that calculates the total number of hours for a timecard and displays it on the page
B. A Roll-Up Summary field on the Timecard Object that calculates the total hours from timecard entries for that timecard
C. A Process Builder process that updates a field on the timecard when a timecard entry is created
D. An Apex trigger that uses an Aggregate Query to calculate the hours for a given timecard and stores it in a custom field

A

Given that a timecard entry has a Master-Detail relationship to a timecard, the most suitable and declarative approach to calculate the total hours for each timecard would be:

B. A Roll-Up Summary field on the Timecard Object that calculates the total hours from timecard entries for that timecard

Roll-Up Summary fields are a native feature of Salesforce that allows aggregation of data from child records (detail) into the parent record (master) in Master-Detail relationships.

Let’s review the other options:

A. A Visualforce page: This is not a purely declarative option. While it can display the calculated total hours, it introduces additional complexity and is less efficient than using a Roll-Up Summary field.

C. A Process Builder process: While Process Builder can update fields based on criteria, it’s not the best tool for aggregating data from child records to a parent record. Using Roll-Up Summary fields is more efficient for this purpose.

D. An Apex trigger: This is not a declarative approach. Although it can be used to aggregate data, it requires writing, testing, and maintaining code. When there’s a declarative solution available (like Roll-Up Summary fields), it’s recommended to use that solution for simplicity and ease of maintenance.

Thus, the best choice is:
B. A Roll-Up Summary field on the Timecard Object that calculates the total hours from timecard entries for that timecard.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

A developer encounters APEX heap limit errors in a trigger.
Which two methods should the developer use to avoid this error? (Choose two.)
A. Use the transient keyword when declaring variables.
B. Query and store fields from the related object in a collection when updating related objects.
C. Remove or set collections to null after use.
D. Use SOQL for loops instead of assigning large queries results to a single collection and looping through the collection.

A

APEX heap limit errors occur when the memory being used by the variables, collections, and other transient elements in the code exceeds the limit set by Salesforce. To avoid these errors, the following methods can be employed:

C. Remove or set collections to null after use: After processing the data in a collection, it’s a good practice to set the collection to null or clear it to free up heap memory.

D. Use SOQL for loops instead of assigning large queries results to a single collection and looping through the collection: SOQL for loops allow you to iterate over the records returned by a SOQL query without holding them all in memory at once. This approach minimizes heap size usage as compared to fetching all records into a collection and then looping through the collection.

Let’s review the other options:

A. Use the transient keyword when declaring variables: The transient keyword is mainly used in Visualforce controllers to ensure that the variable doesn’t retain its value between requests, helping to reduce view state size. It doesn’t reduce the heap size in APEX triggers.

B. Query and store fields from the related object in a collection when updating related objects: This method might not necessarily reduce heap size. In fact, if you’re querying additional data and storing it in memory, it might increase the heap size, depending on the amount of data.

Thus, the best choices are:
C. Remove or set collections to null after use.
D. Use SOQL for loops instead of assigning large query results to a single collection and looping through the collection.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which approach should be used to provide test data for a test class?
A. Query for existing records in the database.
B. Execute anonymous code blocks that create data.
C. Use a test data factory class to create test data.
D. Access data in @TestVisible class variables.

A

The best practice for providing test data for a test class is:

C. Use a test data factory class to create test data.

Using a test data factory helps in centralizing the test data creation logic, making it easier to maintain and reuse across multiple test classes. It ensures that your test data is consistent, and you don’t have to rewrite the same data creation logic repeatedly for different test methods or classes.

Let’s analyze the other options:

A. Query for existing records in the database: This is not a recommended approach because test methods should be able to run in any org, regardless of the existing data. Relying on production data can lead to flaky tests that might fail in different environments. By default, Salesforce test methods don’t have access to existing data unless SeeAllData=true is used, which is generally discouraged.

B. Execute anonymous code blocks that create data: This method is used for executing Apex code snippets on the fly, usually from the developer console. It’s not an appropriate or efficient way to provide test data for a test class.

D. Access data in @TestVisible class variables: The @TestVisible annotation allows test methods to access private or protected members (variables, methods) of other classes directly. This doesn’t pertain directly to the creation of test data but rather to the accessibility of specific variables or methods during testing.

Thus, the most recommended approach is:
C. Use a test data factory class to create test data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Which approach should a developer take to automatically add a Maintenance Plan to each Opportunity that includes an Annual Subscription when an opportunity is closed?
A. Build a OpportunityLineItem trigger that adds a PriceBookEntry record.
B. Build an OpportunityLineItem trigger to add an OpportunityLineItem record.
C. Build an Opportunity trigger that adds a PriceBookEntry record.
D. Build an Opportunity trigger that adds an OpportunityLineItem record.

A

To automatically add a “Maintenance Plan” to each Opportunity that includes an “Annual Subscription” when an opportunity is closed, we need to consider the following:

The “Maintenance Plan” would be a type of product or service, which in Salesforce would be represented by an OpportunityLineItem (since it’s related to a specific opportunity).

“Annual Subscription” would also be an OpportunityLineItem under the Opportunity.

When an opportunity is closed, the trigger should evaluate the existing OpportunityLineItems to check if there’s an “Annual Subscription”. If there is, then another OpportunityLineItem for the “Maintenance Plan” should be added to the Opportunity.

Considering the options:

A. Build an OpportunityLineItem trigger that adds a PriceBookEntry record: This is incorrect because adding a PriceBookEntry wouldn’t achieve the requirement. We need to add an OpportunityLineItem related to the Opportunity.

B. Build an OpportunityLineItem trigger to add an OpportunityLineItem record: This could work, but it might not be the most efficient. If an Opportunity has multiple line items, the trigger would run for each line item, which could lead to inefficiencies or recursion.

C. Build an Opportunity trigger that adds a PriceBookEntry record: This is incorrect for the same reason as option A.

D. Build an Opportunity trigger that adds an OpportunityLineItem record: This is the best approach. By building a trigger on the Opportunity object, you can check when the Opportunity status changes to closed, evaluate the associated OpportunityLineItems for “Annual Subscription”, and then add a new OpportunityLineItem for the “Maintenance Plan” if needed.

The most appropriate answer is:
D. Build an Opportunity trigger that adds an OpportunityLineItem record.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Which two statements are true about using the @testSetup annotation in an Apex test class? (Choose two.)
A. The @testSetup annotation cannot be used when the @isTest(SeeAllData=True) annotation is used. Most Voted
B. Test data is inserted once for all test methods in a class. Most Voted
C. Records created in the @testSetup method cannot be updates in individual test methods.
D. The @testSetup method is automatically executed before each test method in the test class is executed.

A

The @testSetup annotation in Apex is used to define methods that set up test data for test classes. Here are the correct statements regarding its usage:

A. The @testSetup annotation cannot be used when the @isTest(SeeAllData=True) annotation is used: This statement is true. If @isTest(SeeAllData=True) is defined for a class, @testSetup cannot be used. This is because @testSetup is meant to isolate test data, while SeeAllData=True provides access to organisation data.

B. Test data is inserted once for all test methods in a class: This statement is also true. Methods with the @testSetup annotation are run once before any test method in the test class. This helps to reduce the redundancy of test data setup for each test method and can help to improve the performance of test execution.

Regarding the other options:

C. Records created in the @testSetup method cannot be updated in individual test methods: This statement is false. Records created in a @testSetup method are accessible and can be updated in individual test methods. However, changes made to these records within a test method are only available to that specific test method.

D. The @testSetup method is automatically executed before each test method in the test class is executed: This statement is false. The @testSetup method is executed only once before any test method in the class, not before each test method.

So, the correct answers are:
A. The @testSetup annotation cannot be used when the @isTest(SeeAllData=True) annotation is used.
B. Test data is inserted once for all test methods in a class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the requirement for a class to be used as a custom Visualforce controller?
A. Any top-level Apex class that has a constructor that returns a PageReference
B. Any top-level Apex class that extends a PageReference
C. Any top-level Apex class that has a default, no-argument constructor Most Voted
D. Any top-level Apex class that implements the controller interface

A

For a class to be used as a custom Visualforce controller:

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

This means that the class should have a constructor that takes no arguments. Visualforce uses this constructor when it instantiates the controller or extension to ensure it can create an instance without passing parameters.

Regarding the other options:

A. Any top-level Apex class that has a constructor that returns a PageReference: While a custom controller or extension can have methods that return a PageReference to redirect the user to different pages, this is not a requirement for the class to act as a controller.

B. Any top-level Apex class that extends a PageReference: This is not accurate. PageReference is not something you typically extend for a custom controller.

D. Any top-level Apex class that implements the controller interface: There’s no specific “controller interface” in Apex that classes must implement to be used as a custom Visualforce controller.

So, the correct answer is:
C. Any top-level Apex class that has a default, no-argument constructor.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

A newly hired developer discovers that there are multiple triggers on the case object.
What should the developer consider when working with triggers?
A. Developers must dictate the order of trigger execution.
B. Trigger execution order is based on creation date and time.
C. Unit tests must specify the trigger being tested.
D. Trigger execution order is not guaranteed for the same sObject.

A

The correct statement regarding trigger execution in Salesforce is:

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

Multiple triggers for the same event (e.g., before update, after insert) on the same sObject are not guaranteed to execute in any specific order. This can sometimes lead to unexpected behavior if there are multiple triggers on the same object, especially if those triggers have conflicting operations. It’s a best practice to have one trigger per object and use that trigger to call classes or methods to keep the logic organized and avoid conflicts.

Regarding the other options:

A. Developers must dictate the order of trigger execution: Developers cannot dictate the order of execution for multiple triggers on the same sObject.

B. Trigger execution order is based on creation date and time: This statement is false. Salesforce does not guarantee trigger execution order based on creation date and time.

C. Unit tests must specify the trigger being tested: This is not accurate. When testing, you usually aim to test the logic and functionality rather than specifying which trigger to run. The trigger runs based on the DML operations in the test method.

So, the correct answer is:
D. Trigger execution order is not guaranteed for the same sObject.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

How should a developer prevent a recursive trigger?
A. Use a ג€one trigger per objectג€ pattern.
B. Use a static Boolean variable.
C. Use a trigger handler.
D. Use a private Boolean variable.

A

To prevent a recursive trigger, the most common and recommended approach is:

B. Use a static Boolean variable.

By using a static Boolean variable, you can ensure the trigger only runs once during the transaction. For instance:

apex
Copy code
public class TriggerHelper {
public static Boolean isTriggerAlreadyRun = false;
}
In the trigger:

apex
Copy code
trigger MyTrigger on MyObject__c (before insert) {
if(!TriggerHelper.isTriggerAlreadyRun) {
TriggerHelper.isTriggerAlreadyRun = true;
// trigger logic here
}
}
However, some other options are related to best practices or patterns:

A. Use a ‘one trigger per object’ pattern: While this is a best practice to maintain trigger organization and readability, it doesn’t inherently prevent recursion.

C. Use a trigger handler: This is another best practice to move logic out of the trigger itself and into a class (handler). This makes the logic more modular and maintainable. A trigger handler often uses a static Boolean variable to prevent recursion, so it’s somewhat related but isn’t the direct answer to the question.

D. Use a private Boolean variable: A private Boolean variable would not maintain its state across trigger executions in the same transaction. Hence, it wouldn’t prevent recursion. Only static variables maintain their state across trigger executions in the same transaction.

So, the most direct answer to the question is:
B. Use a static Boolean variable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Which three options can be accomplished with formula fields? (Choose three.)
A. Generate a link using the HYPERLINK function to a specific record.
B. Display the previous value for a field using the PRIORVALUE function.
C. Determine if a datetime field value has passed using the NOW function.
D. Return and display a field value from another object using the VLOOKUP function.
E. Determine which of three different images to display using the IF function.

A

Among the given options, the three tasks that can be accomplished using formula fields are:

A. Generate a link using the HYPERLINK function to a specific record.
This function creates a link to a URL or a Salesforce record. For example, HYPERLINK(“/” & Id, Name) would create a link to the record itself using the record’s name as the link text.

C. Determine if a datetime field value has passed using the NOW function.
The NOW() function returns the current date and time. You can use it in comparisons with datetime fields to see if a certain date and time have passed.

E. Determine which of three different images to display using the IF function.
The IF() function allows for conditional logic. You can use it in conjunction with the IMAGE() function to display different images based on certain criteria.

For clarity:

B. Display the previous value for a field using the PRIORVALUE function.
The PRIORVALUE function is used in workflow field update formulas and not in formula fields to get the previous value of a field.

D. Return and display a field value from another object using the VLOOKUP function.
There is no VLOOKUP function in Salesforce formula fields. This function is more associated with Excel. In Salesforce, you’d typically use relationships to get data from related objects.

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is a capability of the <ltng:require> tag that is used for loading external Javascript libraries in Lightning Component? (Choose three.)
A. Loading files from Documents.
B. One-time loading for duplicate scripts.
C. Specifying loading order.
D. Loading scripts in parallel.
E. Loading externally hosted scripts.</ltng:require>

A

The <ltng:require> tag in Lightning Components is used to include external JavaScript/CSS libraries. Among the given options, the capabilities of the <ltng:require> tag are:</ltng:require></ltng:require>

B. One-time loading for duplicate scripts.
If the same script is requested multiple times (maybe from different components), the Lightning framework ensures it’s loaded only once.

C. Specifying loading order.
You can specify the order of scripts using the afterScriptsLoaded attribute. The scripts specified in the scripts attribute are loaded first, and once they’re all loaded, any functions specified in afterScriptsLoaded are executed.

D. Loading scripts in parallel.
The Lightning framework loads the scripts specified in the scripts attribute in parallel for performance reasons, but the callback in afterScriptsLoaded ensures that your specified function only runs after all those scripts are loaded.

Regarding the other options:

A. Loading files from Documents.
Files from Documents are not directly loadable using <ltng:require>. Typically, you'd load libraries from static resources.</ltng:require>

E. Loading externally hosted scripts.
It’s a best practice to load scripts from Salesforce’s static resources rather than externally hosted scripts to ensure they’re available in Salesforce’s security context and to improve performance. The Lightning Locker Service also imposes restrictions which can make working with externally hosted scripts more complex.

So, the correct capabilities are:
B. One-time loading for duplicate scripts.
C. Specifying loading order.
D. Loading scripts in parallel.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

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.)
A. Make an outbound web services call to the SOAP API.
B. Hardcode the ID as a constant in an Apex class.
C. Use the getRecordTypeInfosByName() method in the DescribeSObjectResult class.
D. Execute a SOQL query on the RecordType object.

A

To dynamically determine the ID of a Record Type by its name, a developer has a couple of options:

C. Use the getRecordTypeInfosByName() method in the DescribeSObjectResult class.

This method provides a way to get the record type information by name without the need for any SOQL query.

Regarding the other options:

A. Make an outbound web services call to the SOAP API.
This approach is not efficient, especially when you can get the record type ID directly in Apex. Making an external callout also has governor limits and can introduce unnecessary complexity.

B. Hardcode the ID as a constant in an Apex class.
Hardcoding IDs is not recommended because IDs can change between environments (e.g., sandbox to production) and can lead to problems when migrating code.

So, the correct options are:
C. Use the getRecordTypeInfosByName() method in the DescribeSObjectResult class.
D. Execute a SOQL query on the RecordType object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

A developer has the controller class below.

Which code block will run successfully in an execute anonymous window?
A. myFooController m = new myFooController(); System.assert(m.prop !=null);
B. myFooController m = new myFooController(); System.assert(m.prop ==0);
C. myFooController m = new myFooController(); System.assert(m.prop ==null);
D. myFooController m = new myFooController(); System.assert(m.prop ==1);

A

However, let’s assume some basic behaviors:

If prop is an instance property of type Integer and is not initialized, its default value will be null.

If prop is a static property of type Integer and is not initialized, its default value will still be null.

Based on the above general behaviors:

Option A is checking if prop is not null.
Option B is checking if prop is 0.
Option C is checking if prop is null.
Option D is checking if prop is 1.

If prop is an instance variable of type Integer and hasn’t been initialized in the constructor or elsewhere in the class, the correct answer would be:

C. myFooController m = new myFooController(); System.assert(m.prop == null);

Again, this is based on the assumption, and the actual answer might vary depending on the content of the “myFooController” class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

In a single record, a user selects multiple values from a multi-select picklist.
How are the selected values represented in Apex?
A. As a List<String> with each value as an element in the list
B. As a String with each value separated by a comma
C. As a String with each value separated by a semicolon
D. As a Set<String> with each value as an element in the set</String></String>

A

In Apex, the selected values from a multi-select picklist are represented:

C. As a String with each value separated by a semicolon

So, when working with multi-select picklist values in Apex, you often need to use methods like split(‘;’) to convert the string into a list of individual values.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What are two valid options for iterating through each Account in the collection List<Account> named AccountList? (Choose two.)
A. for (Account theAccount : AccountList) {ג€¦}
B. for(AccountList) {ג€¦}
C. for (List L : AccountList) {ג€¦}
D. for (Integer i=0; i < AccountList.Size(); i++) {ג€¦}</Account>

A

The valid options for iterating through each Account in the collection List<Account> named AccountList are:</Account>

A. for (Account theAccount : AccountList) {…}
D. for (Integer i=0; i < AccountList.Size(); i++) {…}

These are the standard ways to iterate through lists in Apex, either using the enhanced for loop (for-each style) or the traditional for loop using an index.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

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.)
A. for (ID accountID : accountMap.keySet()) {ג€¦}
B. for (Account accountRecord : accountMap.values()) {ג€¦}
C. for (Integer i=0; I < accountMap.size(); i++) {ג€¦}
D. for (ID accountID : accountMap) {ג€¦}
E. for (Account accountRecord : accountMap.keySet()) {ג€¦}

A

Given the Map<ID, Account> accountMap, the valid loop structures for iterating through items in the collection are:

A. for (ID accountID : accountMap.keySet()) {…}

This loops through the set of keys (in this case, IDs) of the map.
B. for (Account accountRecord : accountMap.values()) {…}

This loops through the collection of values (in this case, Account records) of the map.
D. for (ID accountID : accountMap) {…}

This is a shorthand way to loop through the keys of the map.
Options C and E are not valid for the following reasons:

C. The structure provided is the typical loop structure for lists and arrays. However, you cannot directly index into a map using an integer. Maps are not ordered lists.

E. accountMap.keySet() returns a set of IDs, so trying to loop through them and assign each ID to an Account variable would result in a type mismatch.

So, the correct answers are A, B, and D.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

Universal Containers wants Opportunities to be locked from editing when reaching the Closed/Won stage.
Which two strategies should a developer use to accomplish this? (Choose two.)
A. Use a Visual Workflow.
B. Use a validation rule.
C. Use the Process Automation Settings.
D. Use a Trigger.

A

To lock Opportunities from editing when they reach the Closed/Won stage, a developer can:

B. Use a validation rule.
- A validation rule can be created to prevent users from making changes to an Opportunity when its stage is “Closed/Won.” The rule formula can check if the stage is “Closed/Won” and if any fields have been changed. If so, the validation rule can display an error message to the user, preventing the edit.

D. Use a Trigger.
- An Apex trigger on the Opportunity object can be written to run before an update. Within this trigger, the code can check if the Opportunity’s stage is “Closed/Won” and if any fields are being edited. If these conditions are met, the trigger can add an error to the record, thereby preventing the changes from being saved.

Using a Visual Workflow (Option A) is typically for more complex automation and orchestration of processes. While it could technically be used to enforce logic like this, it’s a bit overkill for the simple requirement of preventing edits.

Process Automation Settings (Option C) generally refer to settings related to the order of execution and not to the specific functionality of locking records.

Therefore, the best strategies in this case are B and D.

27
Q

How should a developer make sure that a child record on a custom object, with a lookup to the Account object, has the same sharing access as its associated account?
A. Create a Sharing Rule comparing the custom object owner to the account owner.
B. Create a validation rule on the custom object comparing the record owners on both records.
C. Include the sharing related list on the custom object page layout.
D. Ensure that the relationship between the objects is Master-Detail.

A

To make sure that a child record on a custom object has the same sharing access as its associated account:

D. Ensure that the relationship between the objects is Master-Detail.

In Salesforce, when a custom object is in a Master-Detail relationship (with the Account being the master), the detail (child) record inherits the sharing settings of its master (parent) record. Thus, if the Account has certain sharing rules applied to it, the child record in the custom object will inherit those same sharing rules.

Options A, B, and C won’t ensure the same sharing access between the child custom object and its associated Account:

A. Sharing Rules might provide additional sharing above and beyond the owner’s access, but it won’t necessarily ensure “the same” sharing access.
B. Validation rules are for data consistency and not for controlling sharing.
C. The sharing related list displays the sharing entries for a record but doesn’t control the sharing.

So, the correct answer is D.

28
Q

An org has a single account named ˜NoContacts' that has no related contacts. Given the query: List<Account> accounts = [Select ID, (Select ID, Name from Contacts) from Account where Name=˜NoContacts’];
What is the result of running this Apex?
A. accounts[0].contacts is invalid Apex.
B. accounts[0].contacts is an empty Apex.
C. accounts[0].contacts is Null.
D. A QueryException is thrown.

A

Given the query, the inner subquery (Select ID, Name from Contacts) is retrieving related contacts for the account named ‘NoContacts’.

When the account named ‘NoContacts’ has no related contacts, the subquery doesn’t throw an exception. Instead, it simply returns an empty list of contacts for that account.

So, the correct answer is:

B. accounts[0].contacts is an empty list.

29
Q

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.)
A. action Most Voted
B. renderAs
C. standardController Most Voted
D. readOnly
E. extensions Most Voted</apex:page>

A

To accomplish the described requirements:

action: This attribute specifies a method to be executed when the page is loaded. This can be used to perform the calculations before the page is displayed.
standardController: This specifies which Salesforce standard or custom object to use with the page. In this case, it would be set to “Account”.
extensions: This attribute specifies a comma-separated list of Apex classes that extend the functionality of the page’s standard controller. This could be used to add additional functionality to the Account controller.
Therefore, the correct choices are:
A. action
C. standardController
E. extensions

30
Q

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?
A. The API name is not changed and there are no other impacts. Most Voted
B. The API name of the field and the reference in the test class is changed.
C. The API name of the field is changed, and a warning is issued to update the class.
D. The API name of the field and the reference in the test class is updated.

A

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

When you change the API name of a field, any references in Apex, formulas, or other places will not automatically update. This can lead to errors or failures in those components. The Schema Builder won’t prevent you from making the change, but you’d need to manually update any references in your code or configurations to reflect the new API name.

31
Q

When is an Apex Trigger required instead of a Process Builder Process?
A. When a record needs to be created
B. When multiple records related to the triggering record need to be updated
C. When a post to Chatter needs to be created
D. When an action needs to be taken on a delete or undelete, or before a DML operation is executed.

A

The correct answer is:
D. When an action needs to be taken on a delete or undelete, or before a DML operation is executed.

Explanation:

A. Process Builder can create records.
B. Process Builder can update related records.
C. Process Builder can post to Chatter.
D. Triggers are required when you need to handle logic before a record is saved (before triggers) or when you need to handle logic on delete/undelete operations. Process Builder only handles after insert and after update events.

32
Q

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?
A. Create and populate a custom field on the parent object marked as Unique.
B. Create a custom field on the child object of type External Relationship.
C. Create and populate a custom field on the parent object marked as an External ID. Most Voted
D. Create a custom field on the child object of type Foreign Key.

A

The correct action to relate records in the data model without knowing the Salesforce ID, using a foreign key attribute, is:

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

Salesforce allows the use of External IDs for this purpose. An External ID is a custom field that has the “External ID” attribute, meaning it contains unique record identifiers from a system outside of Salesforce. When you use upsert operations or data loading tools, you can match records using this External ID instead of the Salesforce ID. This is especially useful when integrating with external systems.

33
Q

A developer created a Lightning component to display a short text summary for an object and wants to use it with multiple Apex classes.
How should the developer design the Apex classes?
A. Have each class define method getObject() that returns the sObject that is controlled by the Apex class.
B. Extend each class from the same base class that has a method getTextSummary() that returns the summary.
C. Have each class implement an interface that defines method getTextSummary() that returns the summary. Most Voted
D. Have each class define method getTextSummary() that returns the summary.

A

Among the provided options, the best practice for ensuring consistent behavior across multiple Apex classes, especially when you want to guarantee that each class provides a specific method, is to use interfaces.

So, the correct answer is:

C. Have each class implement an interface that defines method getTextSummary() that returns the summary.

By using an interface, you can ensure that every class that implements the interface provides the necessary getTextSummary() method. This makes it clear and consistent for the Lightning component (or any other calling context) to interact with those classes, as it can always expect the getTextSummary() method to be available.

34
Q

Which approach should a developer use to add pagination to a Visualforce page?
A. A StandardController
B. The Action attribute for a page
C. The extensions attribute for a page
D. A StandardSetController

A

To add pagination to a Visualforce page, the best approach is:

D. A StandardSetController

The StandardSetController in Salesforce provides built-in methods to implement pagination such as next(), previous(), getHasNext(), and getHasPrevious(). This makes it the ideal choice for paginating lists of records on a Visualforce page.

35
Q

A developer is asked to create a PDF quote document formatted using the company’s branding guidelines, and automatically save it to the Opportunity record.
Which two ways should a developer create this functionality? (Choose two.)
A. Install an application from the AppExchange to generate documents.
B. Create a Visualforce page with custom styling.
C. Create an email template and use it in Process Builder.
D. Create a visual flow that implements the company’s formatting.

A

To create a PDF quote document formatted using the company’s branding guidelines and automatically save it to the Opportunity record, two potential solutions are:

B. Create a Visualforce page with custom styling.

By using a Visualforce page with the attribute renderAs=”pdf”, a developer can transform a Visualforce page into a PDF format. Custom styling (using CSS) can ensure the document aligns with the company’s branding guidelines. Once the PDF is generated, it can be saved to the related Opportunity record.
A. Install an application from the AppExchange to generate documents.

There are several third-party applications available on Salesforce’s AppExchange that offer document generation capabilities, including creating PDFs. Depending on the requirements, one of these apps might be a fit, offering a range of customization and functionality options.
Options C and D aren’t direct or standard methods for generating and saving a PDF formatted document to an Opportunity record in Salesforce.

36
Q

Which tool allows a developer to send requests to the Salesforce REST APIs and view the responses?
A. REST resource path URL
B. Workbench REST Explorer
C. Developer Console REST tab
D. Force.com IDE REST Explorer tab

A

The tool that allows a developer to send requests to the Salesforce REST APIs and view the responses is:

B. Workbench REST Explorer

Workbench provides a web-based interface for interacting with Salesforce APIs, including the REST API. The REST Explorer within Workbench is a helpful tool for developers to test and explore the Salesforce REST API endpoints.

37
Q

A developer created a Visualforce page and a custom controller with methods to handle different buttons and events that can occur on the page.
What should the developer do to deploy to production?
A. Create a test class that provides coverage of the Visualforce page.
B. Create a test page that provides coverage of the Visualforce page.
C. Create a test page that provides coverage of the custom controller.
D. Create a test class that provides coverage of the custom controller.

A

When deploying to production in Salesforce, especially when working with custom controllers, it is important to have test classes to ensure that your code works as expected and meets the Salesforce code coverage requirement.

The correct answer is:

D. Create a test class that provides coverage of the custom controller.

Salesforce requires a minimum of 75% code coverage for custom code (Apex) to be deployed to a production environment. By creating a test class that provides coverage for the custom controller, the developer can ensure that the controller’s methods and logic are tested and that the deployment will meet Salesforce’s coverage criteria.

38
Q

What is a benefit of using an after insert trigger over using a before insert trigger?
A. An after insert trigger allows a developer to bypass validation rules when updating fields on the new record.
B. An after insert trigger allows a developer to insert other objects that reference the new record.
C. An after insert trigger allows a developer to make a callout to an external service.
D. An after insert trigger allows a developer to modify fields in the new record without a query.

A

The primary difference between “before insert” and “after insert” triggers is in the state of the transaction. In a “before insert” trigger, the record hasn’t been saved to the database yet, whereas in an “after insert” trigger, the record has already been committed to the database.

Given the options:

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

This is the correct answer. In an “after insert” trigger, the record has been saved, and thus it has a Salesforce ID. This allows you to create related records that reference the newly inserted record by its ID. In contrast, in a “before insert” trigger, the record hasn’t been assigned an ID yet because it hasn’t been saved to the database.

39
Q

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?
A. Create a lookup field on the Construction Job object to the Machinery object.
B. Create a lookup field on the Machinery object to the Construction Job object.
C. Create a junction object with Master-Detail Relationship to both the Machinery object and the Construction Job object. Most Voted
D. Create a Master-Detail Lookup on the Machinery object to the Construction Job object.

A

Given the requirements:

More than one piece of machinery can be assigned to one construction job.
Machinery can be assigned to different construction jobs.
Need to track dates and costs associated with each job for machinery.
The above requirements indicate a many-to-many relationship between Machinery and Construction Job. The most appropriate way to represent a many-to-many relationship in Salesforce is to use a junction object.

So, the correct answer is:

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

This junction object can hold the details like the dates, costs, and any other relevant information associated with the machinery’s assignment to a construction job.

40
Q

Which two strategies should a developer use to avoid hitting governor limits when developing in a multi-tenant environment? (Choose two.)
A. Use collections to store all fields from a related object and not just minimally required fields.
B. Use methods from the ג€Limitsג€ class to monitor governor limits.
C. Use SOQL for loops to iterate data retrieved from queries that return a high number of rows.
D. Use variables within Apex classes to store large amounts of data.

A

In a multi-tenant environment like Salesforce, governor limits are put in place to ensure that no single tenant monopolizes shared resources. To avoid hitting these limits, developers should write efficient and optimized code.

Out of the given options:

B. Use methods from the Limits class to monitor governor limits.

This strategy allows developers to keep track of how close they are to hitting a governor limit in real-time. Using these methods can help prevent reaching the limit by checking the remaining limits before executing operations.
C. Use SOQL for loops to iterate data retrieved from queries that return a high number of rows.

Using SOQL for loops, the platform can retrieve smaller batches of records from the database, which is more efficient than retrieving all records at once, especially when dealing with a large set of data. This approach helps in managing the heap size and reduces the chance of hitting query row limits.
Option A is not necessarily a good practice because storing all fields, especially when not needed, can consume more heap space and make your code less efficient. Option D is not advisable either, as storing large amounts of data in variables might hit the Apex heap size limit.

41
Q

Which set of roll-up types are available when creating a roll-up summary field?
A. COUNT, SUM, MIN, MAX
B. AVERAGE, SUM, MIN, MAX
C. SUM, MIN, MAX
D. AVRAGE, COUNT, SUM, MIN, MAX

A

When creating a roll-up summary field in Salesforce, the available roll-up types are:

A. COUNT, SUM, MIN, MAX

So, the correct answer is A.

42
Q

Which three options allow a developer to use custom styling in a Visualforce page? (Choose three.)
A. <apex:stylesheet> tag
B. Inline CSS
C. <apex:style>tag
D. <apex:stylesheets>tag
E. A static resource</apex:stylesheets></apex:style></apex:stylesheet>

A

In a Visualforce page, a developer can use custom styling through various means. Among the options provided:

B. Inline CSS

Developers can use inline CSS by directly specifying the style attribute in an HTML element.
D. apex:stylesheets tag

This tag allows developers to include multiple stylesheet files in a Visualforce page. These stylesheet files can be uploaded as static resources in Salesforce.
E. A static resource

Static resources allow developers to upload content such as CSS files, JavaScript files, ZIP files, etc., which can be referenced in Visualforce pages. For styling, CSS files can be uploaded as static resources and then referenced in the Visualforce page.
Options A and C, i.e., <apex:stylesheet> and <apex:style>, are not standard Visualforce tags.</apex:style></apex:stylesheet>

So, the correct answers are B, D, and E.

43
Q

Which three tools can deploy metadata to production? (Choose three.)
A. Change Set from Developer Org
B. Force.com IDE Most Voted
C. Data Loader
D. Change Set from Sandbox Most Voted
E. Metadata API Most Voted

A

To deploy metadata to a production Salesforce environment, the following tools from the options given can be used:

B. Force.com IDE

While Force.com IDE was heavily used in the past, it’s worth noting that Salesforce has officially retired this tool. However, its successor, Salesforce CLI (Command Line Interface) along with Visual Studio Code and Salesforce Extensions, can be used to deploy metadata.
D. Change Set from Sandbox

Change sets are a native Salesforce deployment tool that allows developers and admins to move metadata between related Salesforce orgs (like a Sandbox to Production).
E. Metadata API

The Metadata API provides an interface for managing customizations and for building tools that can manage the metadata model, not just the data. It can be used for deployments and is often utilized by other deployment tools behind the scenes.
Among the given options, Data Loader (C) is not used for deploying metadata. It’s primarily a tool for inserting, updating, deleting, or exporting Salesforce records. The option “Change Set from Developer Org” (A) is misleading because change sets are not deployed from developer orgs to production; they’re typically deployed from sandboxes to production.

So, the correct answers are B, D, and E.

44
Q

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.)
A. Use myObject.sObjectType.getDescribe().fieldSet() to return a set of fields.
B. Use mySObject.myObject.fields.getMap() to return a map of fields.
C. Use Schema.describeSObjects(new String[]{myObject})[0].fields.getMap() to return a map of fields. Most Voted
D. Use getGlobalDescribe().get(myObject).getDescribe().fields.getMap() to return a map of fields. Most Voted

A

To retrieve the available fields for an object in Salesforce, developers can utilize the Salesforce Schema methods. Out of the given options, the correct ways to retrieve the fields are:

C. Use Schema.describeSObjects(new String[]{myObject})[0].fields.getMap() to return a map of fields.

This method describes the sObject based on the provided list (in this case, just one object named myObject) and returns a map of its fields.
D. Use getGlobalDescribe().get(myObject).getDescribe().fields.getMap() to return a map of fields.

The getGlobalDescribe() method returns a map of all sObjects. From there, you can retrieve the specific sObject by its name (myObject in this case) and then get a map of its fields.
Options A and B are not standard or correct ways to retrieve the fields of an sObject.

So, the correct answers are C and D.

45
Q

How should a developer avoid hitting the governor limits in test methods?
A. Use @TestVisible on methods that create records.
B. Use Test.loadData() to load data from a static resource.
C. Use @IsTest (SeeAllData=true) to use existing data.
D. Use Test.startTest() to reset governor limits.

A

To avoid hitting governor limits in test methods, Salesforce provides a variety of tools and best practices. Among the provided options:

B. Use Test.loadData() to load data from a static resource.

This allows developers to load test data from a CSV static resource, making the setup more efficient, especially for bulk testing.

46
Q

Which three declarative fields are correctly mapped to variable types in Apex? (Choose three.)
A. Number maps to Decimal.
B. Number maps to Integer.
C. TextArea maps to List of type String.
D. Date/Time maps to Dateline.
E. Checkbox maps to Boolean.

A

I apologize for the oversight. If we’re choosing only three answers, and after rectifying the typo, then:

A. Number maps to Decimal.
B. Number maps to Integer.
E. Checkbox maps to Boolean.

These would be the correct three answers.

47
Q

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?
A. Create an after insert Lead trigger.
B. Create a before insert Lead trigger.
C. Create a Lead Workflow Rule Field Update.
D. Create a Lead formula field.

A

The best approach for setting the value of a field based on a condition during the creation of a record is to use a “before insert” trigger. This allows you to modify the record before it’s committed to the database without needing any additional DML operations.

Thus, the correct answer is:
B. Create a before insert Lead trigger.

48
Q

Why would a developer consider using a custom controller over a controller extension?
A. To increase the SOQL query governor limits.
B. To implement all of the logic for a page and bypass default Salesforce functionality
C. To leverage built-in functionality of a standard controller
D. To enforce user sharing settings and permissions

A

A custom controller in Salesforce is a class written in Apex that implements all of the logic for a page without leveraging the logic provided by a standard controller. On the other hand, a controller extension is used to add to or override the behavior of a standard or custom controller.

Given the options:

A. To increase the SOQL query governor limits. - This isn’t necessarily a reason to choose a custom controller over an extension. The governor limits apply regardless.

B. To implement all of the logic for a page and bypass default Salesforce functionality - This is the main reason for using a custom controller. It provides complete control over the logic without being tied to the default functionality of a standard controller.

C. To leverage built-in functionality of a standard controller - This is the opposite of what you’d want. If you’re trying to leverage the built-in functionality of a standard controller, you’d use a controller extension, not a custom controller.

D. To enforce user sharing settings and permissions - Standard controllers automatically enforce CRUD and FLS, but a custom controller does not, unless you specifically code it.

So, the correct answer is:
B. To implement all of the logic for a page and bypass default Salesforce functionality.

49
Q

A developer wants to override a button using Visualforce on an object.
What is the requirement?
A. The controller or extension must have a PageReference method.
B. The standardController attribute must be set to the object.
C. The action attribute must be set to a controller method.
D. The object record must be instantiated in a controller or extension.

A

When you’re overriding a button using Visualforce on an object, you must use the standardController attribute on the <apex:page> tag and set it to the object you're working with. This is to ensure that the Visualforce page can interact with the object's records.</apex:page>

Therefore, the correct answer is:
B. The standardController attribute must be set to the object.

50
Q

How should a developer create a new custom exception class?
A. public class CustomException extends Exception{}
B. CustomException ex = new (CustomException)Exception();
C. public class CustomException implements Exception{}
D. (Exception)CustomException ex = new Exception();

A

To create a new custom exception class in Apex, you would use the extends keyword to extend the base Exception class.

The correct answer is:
A. public class CustomException extends Exception{}

This creates a new custom exception class named CustomException that extends the standard Exception class.

51
Q

Which two number expressions evaluate correctly? (Choose two.)
A. Double d = 3.14159;
B. Integer I = 3.14159;
C. Decimal d = 3.14159;
D. Long l = 3.14159;

A

The correct options for number expressions that evaluate correctly are:

A. Double d = 3.14159; (Double can store decimal values.)
C. Decimal d = 3.14159; (Decimal is also used for storing decimal values, especially for financial calculations.)

Option B is incorrect because Integer data type can only store whole numbers, not decimal values.
Option D is incorrect because Long data type can only store whole numbers, not decimal values.

52
Q

How can a developer set up a debug log on a specific user?
A. It is not possible to setup debug logs for users other than yourself.
B. Ask the user for access to their account credentials, log in as the user and debug the issue.
C. Create Apex code that logs code actions into a custom object.
D. Set up a trace flag for the user, and define a logging level and time period for the trace.

A

The correct answer is:

D. Set up a trace flag for the user, and define a logging level and time period for the trace.

In Salesforce, to monitor the events or actions of a specific user, you can set up a debug log. By setting a trace flag on a user, you can specify which log levels to collect and for how long.

53
Q

A developer needs to create a Visualforce page that displays Case data. The page will be used by both support reps and support managers. The Support Rep profile does not allow visibility of the Customer_Satisfaction__c field, but the Support Manager profile does.
How can the developer create the page to enforce Field Level Security and keep future maintenance to a minimum?
A. Create one Visualforce Page for use by both profiles. Most Voted
B. Use a new Support Manager permission set.
C. Create a separate Visualforce Page for each profile.
D. Use a custom controller that has the with sharing keywords.

A

The correct answer is:

A. Create one Visualforce Page for use by both profiles. Most Voted

In Salesforce, when creating a Visualforce page, the built-in standard controllers respect the field level security of the user viewing the page. By using one Visualforce page and the standard controller, the platform automatically enforces the field visibility based on the profile of the user. So, a Support Rep wouldn’t see the Customer_Satisfaction__c field if their profile doesn’t have access, while a Support Manager would be able to see it if their profile does. This approach minimizes maintenance since you only have one page to maintain, and field level security changes are managed through profiles, not through changes to the Visualforce page.

54
Q

When an Account’s custom picklist field called Customer Sentiment is changed to a value of Confused, a new related Case should automatically be created.
Which two methods should a developer use to create this case? (Choose two.)
A. Process Builder
B. Apex Trigger
C. Custom Button
D. Workflow Rule

A

To automatically create a related Case when an Account’s custom picklist field called Customer Sentiment is changed to a value of Confused, a developer can use:

A. Process Builder: This tool allows you to automate standard internal procedures and processes to save time across your org. A process can look for changes or events that you specify, then take action when those conditions are met. In this case, it can check for the change in the picklist field and then create a new related Case.

B. Apex Trigger: An Apex trigger enables you to perform custom actions before or after changes to Salesforce records, such as insertions, updates, or deletions. An Apex trigger can be written to listen to the change in the picklist value and create a new related Case when the value is set to Confused.

The other options:

C. Custom Button: It’s a manual action, not automated. The user would have to click the button for any action to take place.

D. Workflow Rule: Workflows allow for field updates, task assignments, email alerts, and outbound messages, but they cannot create new records directly. So, this option is not suitable for the requirement mentioned.

55
Q

What are three characteristics of static methods? (Choose three.)
A. Initialized only when a class is loaded
B. A static variable outside of the scope of an Apex transaction
C. Allowed only in outer classes
D. Allowed only in inner classes
E. Excluded from the view state for a Visualforce page

A

Static methods in Apex have the following characteristics:

A. Initialized only when a class is loaded: This isn’t precisely true for static methods. It’s static variables that are initialized only when a class is loaded. However, static methods are associated with the class itself rather than instances of the class.

C. Allowed only in outer classes: This is true. Static methods are permitted in outer classes but not in inner classes.

E. Excluded from the view state for a Visualforce page: This is correct. Static variables do not retain their values and are not stored in the view state of a Visualforce page. This helps in reducing the view state size.

The other options:

B. A static variable outside of the scope of an Apex transaction: This describes static variables, not static methods. Static variables retain their values within the execution context of a single transaction.

D. Allowed only in inner classes: This is incorrect. Static methods are not allowed in inner classes.

56
Q

What are two uses for External IDs? (Choose two.)
A. To create relationships between records imported from an external system.
B. To create a record in a development environment with the same Salesforce ID as in another environment
C. To identify the sObject type in Salesforce
D. To prevent an import from creating duplicate records using Upsert

A

External IDs in Salesforce are used for:

A. To create relationships between records imported from an external system: This is correct. External IDs are often used to relate imported records to other records in Salesforce based on an identifier from an external system.

D. To prevent an import from creating duplicate records using Upsert: This is correct. When performing an upsert operation, Salesforce uses the External ID to determine whether it should create a new record or update an existing one, thus preventing duplicates.

The other options:

B. To create a record in a development environment with the same Salesforce ID as in another environment: This is incorrect. Salesforce IDs are unique and cannot be replicated across environments using External IDs.

C. To identify the sObject type in Salesforce: This is incorrect. The sObject type is determined by the API name of the object, not by the External ID.

57
Q

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?
A. Use try/catch within the unit test to catch the exception.
B. Use the finally bloc within the unit test to populate the exception.
C. Use the database methods with all or none set to FALSE.
D. Use Test.isRunningTest() within the custom controller.

A

The correct approach to handle this scenario would be:

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

When testing scenarios in which you expect exceptions to be thrown, you should use a try/catch block in the unit test. This way, you can assert that the expected exception was thrown, ensuring your code behaves as intended.

58
Q

Which SOQL query successfully returns the Accounts grouped by name?
A. SELECT Type, Max(CreatedDate) FROM Account GROUP BY Name
B. SELECT Name, Max(CreatedDate) FROM Account GROUP BY Name
C. SELECT Id, Type, Max(CreatedDate) FROM Account GROUP BY Name
D. SELECT Type, Name, Max(CreatedDate) FROM Account GROUP BY Name LIMIT 5

A

When using SOQL with the GROUP BY clause, all fields in the SELECT clause, apart from aggregate functions, need to be part of the GROUP BY clause.

From the given options:

A. SELECT Type, Max(CreatedDate) FROM Account GROUP BY Name - This query does not include the ‘Type’ in the GROUP BY clause, so it’s incorrect.

B. SELECT Name, Max(CreatedDate) FROM Account GROUP BY Name - This query is correct because ‘Name’ is both in the SELECT and GROUP BY clauses.

C. SELECT Id, Type, Max(CreatedDate) FROM Account GROUP BY Name - This query includes ‘Id’ and ‘Type’ in the SELECT but not in the GROUP BY clause, making it incorrect.

D. SELECT Type, Name, Max(CreatedDate) FROM Account GROUP BY Name LIMIT 5 - This query does not include the ‘Type’ in the GROUP BY clause, so it’s incorrect.

The correct answer is:

B. SELECT Name, Max(CreatedDate) FROM Account GROUP BY Name

59
Q

For which three items can a trace flag be configured? (Choose three.)
A. Apex Trigger
B. Apex Class
C. Process Builder
D. User
E. Visualforce

A

A trace flag in Salesforce is used to set logging levels for specific users or system components to troubleshoot issues. Trace flags include log levels for various components and can be applied to users or specific Apex classes and triggers.

From the given options:

A. Apex Trigger - Yes, you can set a trace flag for an Apex Trigger.

B. Apex Class - Yes, you can set a trace flag for an Apex Class.

C. Process Builder - No, trace flags can’t be set specifically for Process Builder.

D. User - Yes, you can set a trace flag for a specific User.

E. Visualforce - No, trace flags can’t be set specifically for Visualforce.

So, the correct answers are:

A. Apex Trigger
B. Apex Class
D. Usef

60
Q

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.)
A. Use a standard controller.
B. Use a standard controller with extensions.
C. Use a custom controller with extensions. Most Voted
D. Do not specify a controller. Most Voted
E. Use a custom controller. Most Voted

A
61
Q

A Platform Developer needs to implement a declarative solution that will display the most recent Closed Won date for all Opportunity records associated with an
Account.
Which field is required to achieve this declaratively?
A. Roll-up summary field on the Opportunity object
B. Cross-object formula field on the Opportunity object
C. Roll-up summary field on the Account object
D. Cross-object formula field on the Account object

A

The correct answer is:

C. Roll-up summary field on the Account object

To capture aggregated information from related child records (like Opportunities) and display it on the parent record (like Account), you would use a roll-up summary field. In this case, since you’re looking to capture the most recent Closed Won date for Opportunities on the Account, you would create a roll-up summary field on the Account object that calculates the MAX (most recent) Closed Won date from its associated Opportunities.

62
Q

What is the data type returned by the following SOSL search?
[FIND `˜Acme*’ IN NAME FIELDS RETURNING Account, Opportunity];
A. List<List<Account>, List<Opportunity>>
B. Map<sObject, sObject>
C. List<List<sObject>>
D. Map<Id, sObject></sObject></Opportunity></Account>

A

The correct answer is:

C. List<List<sObject>></sObject>

When you perform a SOSL search, it returns a List of List<sObject> where each inner list represents the records of a particular sObject type specified in the SOSL query. In the given SOSL search, the first inner list will have the records of Account, and the second inner list will have the records of Opportunity.</sObject>

63
Q

A company wants to create an employee rating program that allows employees to rate each other. An employee’s average rating must be displayed on the employee record. Employees must be able to create rating records, but are not allowed to create employee records.
Which two actions should a developer take to accomplish this task? (Choose two.)
A. Create a trigger on the Rating object that updates a fields on the Employee object. Most Voted
B. Create a lookup relationship between the Rating and Employee object. Most Voted
C. Create a roll-up summary field on the Employee and use AVG to calculate the average rating score.
D. Create a master-detail relationship between the Rating and Employee objects.

A

The correct choices are:

A. Create a trigger on the Rating object that updates a field on the Employee object. Most Voted
B. Create a lookup relationship between the Rating and Employee object. Most Voted

Explanation:

A) A trigger on the Rating object would be necessary to aggregate the ratings and calculate an average rating for an Employee. Since the requirement mentions updating a field on the Employee record to store the average rating, a trigger is a suitable choice.

B) A lookup relationship would be appropriate because while Ratings reference Employees, there isn’t a strict ownership between Rating and Employee, given that Employees cannot be deleted when they have associated Ratings.

C) Roll-up summary fields can be used to perform aggregations, but they are available only when a master-detail relationship exists between objects.

D) A master-detail relationship would enforce strict ownership, meaning that if an Employee record were deleted, all related Rating records would also be deleted. Also, the master (Employee) would control certain behaviors of the detail (Rating) records, like sharing. Since the requirement is that Employees shouldn’t be able to create Employee records but should be able to create Rating records, a master-detail relationship might complicate the setup due to its cascading delete behavior and ownership implications.

64
Q
A