A developer needs to update 10,005 Account records in an organization. What method can the developer use to avoid governor limits? Choose 1 answer.
A. Use Batch APEX
B. Create a method with the @future annotation
C. Write the code in an anonymous block
D. Write code to include a limit clause to restrict the number of records selected for processing
A. Use Batch APEX
Batch APEX can be used to process large numbers of records. Batch Apex operates over small batches of records, covering your entire record set and breaking the processing down to manageable chunks.
An assignment statement is any statement that places a value into a variable. Which one of the following expressions is a valid Apex assignment statement? Choose 1 answer.
A. String a = new String('sampleString');
B. Map<Id, Account> = [SELECT Id, Name FROM Account];
C. Account acc = new Account();
D. List<Contact> conList = new [SELECT Id FROM Contact]
C. Account acc = new Account();
In the correct answer, a new Account object is initialized to the 'acc' variable. However, other options are incorrectly assigned to its variable. The proper way should be:
String a = 'sampleString';Map<Id, Account> mapAcc = new Map<Id, Account>([SELECT Id, Name FROM Account]);List<Contact> conList = [SELECT Id FROM Contact];
Which of the following are capabilities of Visual Studio Code? Choose 3 answers.
A. Creating Change Sets
B. Running Apex Tests
C. Executing SOQL queries
D. Deploying metadata components from one org to another
E. Create a test suite for running tests
B. Running Apex Tests
C. Executing SOQL queries
D. Deploying metadata components from one org to another
Visual Studio Code can be used to:- Test and debug Apex classes and triggers.- Run anonymous blocks of Apex on the server- Execute SOQL queries- Synchronize project contents with changes on the server- Deploy metadata components from one Salesforce organization to another
Creating change sets must be done through the Salesforce web UI of the org. Test suites can only be created in the Developer Console.
A developer is going through the Visualforce pages created in his company's org to identify and fix any potential vulnerabilities. One of the pages uses a static HTML file that has been downloaded from a third-party source. If 'resource_name' refers to the name that was specified when the file was uploaded as a static resource, which of the following should the developer use to reference the file on a separate domain and improve security? Choose 1 answer.
A. $IFrame.
B. $Library.
C. $Resource.
D. $IFrameResource.
D. $IFrameResource.
Static resources that are downloaded from an untrusted third-party source can be isolated using an iframe on a Visualforce page. This adds an extra layer of security to the page and helps protect the assets. To reference a static HTML file on a separate domain, $IFrameResource. can be used as a merge field, where 'resource_name' is the name of the static resource.
A developer has found that test data creation is duplicated across test classes. How can this be eliminated? Choose 1 answer.
A. Creating common test utility classes
B. De-annotating @isTest on methods
C. Making the test methods Public
D. Using one common test class
A. Creating common test utility classes
Common test utility classes are public test classes that contain reusable code for test data creation. It is also commonly known as a Test Data Factory. Public test utility classes are defined with the @isTest annotation, and as such, are excluded from an organization's code size limit and execute in test context. They can be called by test methods but not by non-test code.
There is a requirement to display the total expected revenue of opportunities associated with an Account record. How can this be achieved? Choose 1 answer.
A. Create a trigger on Opportunity to populate a custom field on the Account object
B. Create a roll-up summary field on the Account object using SUM on the Opportunity
C. Create a workflow on the Opportunity object to populate a custom field on the Account object.
D. Create a roll-up summary field on the Opportunity object and display on the Account page layout
B. Create a roll-up summary field on the Account object using SUM on the Opportunity
A roll-up summary field can be defined on the Account object to roll up the expected value of opportunities related to an account. Roll-up summary fields can include filters to only include records that meet certain criteria.
Exceptions show errors and other events that disrupt the normal flow of code execution. Which of the following statements are true about Apex Exception Handling? Choose 3 answers.
A. Comparatively, a throw statement allows you to signal that an error has occurred, while try, catch, and finally can be used to pull through from an exception.
B. The finally statement is required and gets executed after the catch block executes.
C. You can have multiple Catch blocks to catch all different kinds of exceptions. If you use a generic exception catcher, it must be the first Catch block.
D. The try statement identifies a block of code in which an exception could occur.
E. The catch statement identifies a block of code that handles a particular type of exception.
A. Comparatively, a throw statement allows you to signal that an error has occurred, while try, catch, and finally can be used to pull through from an exception.
D. The try statement identifies a block of code in which an exception could occur.
E. The catch statement identifies a block of code that handles a particular type of exception.
The finally statement is not required but gets executed after the catch block executes. The code in this block will always be executed regardless of the type of exception that was thrown and handled. If you need to catch a specific exception/custom exception, it should come first, before the generic exception catcher.
Which of the following statements are true about the "virtual" and "abstract" keywords? Choose 2 answers.
A. Methods declared virtual have a body and can be overridden by an extending class.
B. Methods declared abstract have a body and can be overridden by an extending class.
C. Classes declared abstract can contain both virtual and abstract methods
D. Classes declared virtual can contain both virtual and abstract methods
"A. Methods declared virtual have a body and can be overridden by an extending class.
C. Classes declared abstract can contain both virtual and abstract methods
Virtual classes cannot have methods that are abstract. Only the classes declared Abstract can contain abstract methods. However Abstract classes can have both abstract and virtual methods.
Virtual methods already have a body defined and this body can be overridden by extending classes. Abstract methods only have a signature but no body, and it is up to the extending class to provide the body for the method."
A custom controller is an Apex class that implements all of the logic for a page without leveraging a standard controller. For which situation would a standard list controller be sufficient? Choose 1 answer.
A. Make a callout to an external web service
B. Using object record pagination
C. Running the Visualforce page entirely in system mode
D. Overriding existing standard functionality
B. Using object record pagination
The StandardListController is used for displaying or working on a set of records and comes with built-in pagination features such as next and previous actions for browsing record lists.
Overriding or extending standard functionality, running Visualforce pages in system mode, and performing callouts require a custom controller.
The amount of information contained in a debug log depends on the debug log level set. What are the different levels from lowest amount of information to highest? Choose 1 answer.
A. NONE - ERROR - WARN - INFO - DEBUG - FINE - FINER - FINEST
B. NONE - ERROR - WARN - INFO - FINE - FINER - FINEST- DEBUG
C. NONE - INFO - ERROR - WARN -DEBUG - FINE - FINER - FINEST
D. NONE - FINE - FINER - FINEST - ERROR - WARN - INFO - DEBUG
A. NONE - ERROR - WARN - INFO - DEBUG - FINE - FINER - FINEST
Log levels available in Apex are (listed from lowest to highest): NONE - ERROR - WARN - INFO - DEBUG - FINE - FINER - FINEST.
(Mnemonic: 'NEW Info DF3')
A developer is unable to delete a custom field as it is referenced somewhere in Salesforce. Which of the following might contain the conflicting reference? Choose 3 answers.
A. Formula field
B. Dynamic SOQL
C. Email Template
D. Workflow Field Update
E. Apex Class
A. Formula field
D. Workflow Field Update
E. Apex Class
Below is a list of some of the components that when a field is referenced, the reference should be deleted or updated first before the field can be deleted: Apex Class, Apex Trigger, Visualforce Page, Visualforce Component, Workflow Rule, Field Update, Criteria-Based Sharing Rule, Flow, Jobs, etc.
A developer has created two custom objects with API names 'Sales Order__c' and 'Shipment__c' to track orders and shipments related to them. Sales Order is the parent in the master-detail relationship between the two objects. The Shipment object has a custom field named 'Tracking_Number__c' that indicates the tracking number associated with a particular shipment. The developer is writing an Apex class in which he needs to retrieve all the sales orders and the tracking numbers associated with their shipment records using a SOQL query. Which of the following represents the correct syntax of the query? Choose 1 answer.
A. SELECT Sales_Order__c.Name, Shipment__c.Tracking_Number__c FROM Sales_Order__c, Shipment__c
B. SELECT Name, (SELECT Tracking_Number__c FROM Shipments__r) FROM Sales_Order__c
C. SELECT Name, (SELECT Tracking_Number__c FROM Shipment__c) FROM Sales_Order__c
D. SELECT Name, (SELECT Tracking_Number__c FROM Sales_Order__c.Shipment__c) FROM Sales_Order__c
B. SELECT Name, (SELECT Tracking_Number__c FROM Shipments__r) FROM Sales_Order__c
Parent-child relationships can be traversed in the SELECT clause of a SOQL query by using a nested query. In this case, Shipments__r is the name of the relationship that the parent object named 'Sales_Order__c' has with the child object named 'Shipment__c'.
Cosmic Motors uses 3 custom objects to track motors, the cars they go in, and the components of the motor. The Developer set up the objects to have the labels Motor, Car, and Component, respectively and accepted the default API name for each object. The plural labels of the objects are Motors, Cars, and Components. Motor has a lookup field to Car, while Component has a Master-Detail relationship to Motor. The developer accepted the default child relationship names when these relationship fields were set up. Which of the following queries show the correct syntax for performing relationship queries between these custom objects? Choose 2 answers.
A. SELECT Name, (SELECT Name FROM Component__r) FROM Motor__c WHERE Name LIKE '1000x%'
B. SELECT Name, Car__c.Name FROM Motor__c WHERE Name LIKE '1000x%'
C. SELECT Name, (SELECT Name FROM Components__r) FROM Motor__c WHERE Name LIKE '1000x%'
D. SELECT Name, Car__r.Name FROM Motor__c WHERE Name LIKE '1000x%'
C. SELECT Name, (SELECT Name FROM Components__r) FROM Motor__c WHERE Name LIKE '1000x%'
D. SELECT Name, Car__r.Name FROM Motor__c WHERE Name LIKE '1000x%'
For custom objects, the relationship name is typically formed by taking the plural form of the child object, followed by '__r'. Custom objects themselves append '__c' to the API name. To reference the actual data in a parent field, '__c' needs to be appended, but when querying data from the related parent object, the '__c' is replaced by '__r'. For child objects, the plural form of the API name is used, and once again the '__c' is replaced by '__r'. Remember that to find the child relationship name, the search cannot be made on the parent object, but on the child object where the Lookup or Master-Detail relationship is defined.
In an effort to securely display data in an organization, a developer is modifying any existing custom controllers that do not use a sharing declaration. Which of the following can be used in the definition of a custom controller class to ensure that only records for which the running user has sharing access are displayed when a Visualforce page invokes the class? Choose 2 answers.
A. The 'with sharing' keyword
B. The 'sharing' access modifier
C. The 'protected' access modifier
D. The 'inherited sharing' keyword
A. The 'with sharing' keyword
D. The 'inherited sharing' keyword
Either 'with sharing' or 'inherited sharing' can be used in the definition of a custom controller class to ensure that it respects the running user's organization-wide defaults, role hierarchy, and sharing rules while displaying a Visualforce page that uses the class. Using an explicit sharing declaration ensures that only records for which the running user has sharing access are displayed. Access modifiers are used to define the scope of the methods and variables that are created within an Apex class. They are not used to define sharing declaration.
The solutions architect of a company has rolled out Salesforce DX for the developer team to implement in their application development process. Which of the following are capabilities of Salesforce DX? Choose 3 answers.
A. Developer Console
B. Salesforce Extensions Pack
C. Version Control System
D. Workbench
E. Salesforce CLI
B. Salesforce Extensions Pack
C. Version Control System
E. Salesforce CLI
Salesforce DX involves the use of Salesforce CLI to migrate code and metadata between orgs, and generate scratch orgs, which serve as personal development environments for developers and packages or updates. A version control system is used to manage and track changes. With code and metadata hosted in a code repository, Salesforce CLI can effectively be used to implement continuous integration and continuous deployment.
By using Salesforce Extensions Pack for Visual Studio Code, a developer can easily set up a Salesforce DX project, perform Salesforce CLI commands among other several integrated features, and build Lightning Components, Apex and Visualforce in the editor.
The Developer Console, a web-based IDE that is connected to only one org, and Workbench, an external web-based tool, would not be ideally involved in the development process of a Salesforce DX project.
What is true regarding accessing sharing programmatically? Choose 3 answers.
A. AccountShare is the sharing object for the Account object
B. Objects on the detail side of a master-detail relationship do not have a sharing object
C. Account__Share is the sharing object for the Account object
D. CustomObject__Share is the sharing object for a custom object
A. AccountShare is the sharing object for the Account object
B. Objects on the detail side of a master-detail relationship do not have a sharing object
D. CustomObject__Share is the sharing object for a custom object
To access sharing programmatically, use the share object associated with the standard or custom object you are working with. The naming convention for standard objects simply adds Share to the Object name: AccountShare, CaseShare, ContactShare, etc. Custom objects require appending __Share to the custom object name (but without a "c"). For example, the sharing object for MyCustomObject would be called MyCustomObject__Share.
Objects on the detail side of a master-detail relationship do not have an associated sharing object, access to the detail records are determined by the master object sharing object and the sharing setting of the relationship.
Given the traditional for-loop syntax illustrated in the code snippet below, in what sequential order are the actions in the given steps executed?
I. The initialization expression initializes the for-loop block.
II. The statements in the code block are executed.
III. The exit_condition is evaluated. If true, the loop continues. If false, the loop exits.
IV. The increment statement is executed and then the exit_condition is evaluated.
Choose 1 answer.
for (initialization; exit_condition; increment) {
statements
}
A. I, II, IV, III
B. I, III, II, IV
C. I, II, III, IV
D. III, I, II, IV
B. I, III, II, IV
First, the initialization statement will be executed. Multiple variables can be declared and/or initialized in this statement. Then the exit_condition is evaluated. If the expression evaluates to true, the loop continues. If false, the loop exits. Then the code block inside the loop will be executed. At the end of the code block, the increment expression will be executed. Finally, the exit_condition expression will be evaluated again, either continuing the loop, or exiting as determined by the evaluation.
A Salesforce developer noticed that an Apex method used in their custom Contact management application has been throwing null pointer exceptions on certain occasions. Upon investigating, it was identified that the error was due to code that accesses the Account field of a Contact record, which is not associated with an account, and executes the 'isSet' method on the Account sObject. Given a snippet of the code below, which of the following options can be used to avoid the exception? Choose 1 answer.
public static void assignPrimaryContact() {
Contact con = getContact();
Boolean hasAssigned = con.Account.isSet('Has_Primary_Contact__c ');
// ...
}
A. Boolean hasAssigned = getContact().Account:Account.Has_Primary_Contact__c?null;
B. Boolean hasAssigned = getContact().Account.?isSet('Has_Primary_Contact__c ');
C. Boolean hasAssigned = getContact().Account?Account.Has_Primary_Contact__c:null;
D. Boolean hasAssigned = getContact().Account?.isSet('Has_Primary_Contact__c ');
D. Boolean hasAssigned = getContact().Account?.isSet('Has_Primary_Contact__c ');
The safe navigation operator can be used for replacing explicit checks for null references and uses the syntax "?.", which is a question mark followed by a period. If the left-hand side of the operator evaluates to null, null is returned. Otherwise, the right-hand side, which can contain a method, variable, or property, is chained to the left-hand side of the operator and returned. In this case, the chained value is the 'isSet' method.
So, in the correct answer above, the resulting value that is returned to the 'hasAssigned' variable will be expressed as getContact().Account.isSet('Has_Primary_Contact__c ') if the contact is related to an account.
The other options contain invalid syntax or return values.
A Visualforce page uses a custom Apex controller class. An ID parameter value was passed to the URL. How can a Salesforce developer retrieve the record using this value? Choose 1 answer.
A. Use ApexPages.currentPage().getAnchor() to get the parameter value then make a query to the record using the ID in the controller's constructor.
B. Use ApexPages.currentPage().getParameters() to get the parameter value then make a query to the record using the ID in the controller's constructor.
C. Use ApexPages.currentPage().getContent() to get the parameter value then make a query to the record using the ID in the controller's constructor.
D. Use ApexPages.currentPage().getHeaders() to get the parameter value then make a query to the record using the ID in the controller's constructor.
B. Use ApexPages.currentPage().getParameters() to get the parameter value then make a query to the record using the ID in the controller's constructor.
The getParameters() method can be used to retrieve parameters passed to the URL.
ApexPages.currentPage().getContent() is used to get the rendered output of the Visualforce page. ApexPages.currentPage().getHeaders() is used to get a map of the request headers. ApexPages.currentPage().getAnchor() is used to get the name of the anchor referenced in the page's URL or the hashtag value.
Given the sample log excerpt below, which line(s) correspond to an execution unit of a debug log?
20:43:45.1 (1707921) | EXECUTION_STARTED
20:43:45.1 (1714356) | CODE_UNIT_STARTED | [EXTERNAL] | 01pO0000000Hury | LeadBLTest.setUpTestData
20:43:51.574 (7549778580) | CODE_UNIT_FINISHED | LeadBLTest.setUpTestData
20:43:51.574 (7550987692) | EXECUTION_FINISHED
Choose 1 answer.
A. 1st & 2nd
B. 1st, 2nd, 3rd, & 4th
C. 2nd only
D. 4th only
B. 1st, 2nd, 3rd, & 4th
The execution unit begins on line 1 with EXECUTION_STARTED, ends on line 4 with EXECUTION_FINISHED, and contains everything that occurred within the transaction, including the CODE UNIT on lines 2 and 3.
What are the considerations when building Lightning components? Choose 3 answers.
A. The Developer Console is used for building Lightning Web Components.
B. Lightning components can be built using the Lightning Web Component model and the Aura Component model.
C. Lightning Web Components can contain Aura Components as child components.
D. Lightning Web Components and Aura components can coexist on the same page.
E. Lightning Web Components are custom HTML elements using HTML and modern JavaScript.
B. Lightning components can be built using the Lightning Web Component model and the Aura Component model.
D. Lightning Web Components and Aura components can coexist on the same page.
E. Lightning Web Components are custom HTML elements using HTML and modern JavaScript.
Lightning components can be built using two programming models - Lightning Web Components and Aura Components. Lightning Web Components come with custom HTML elements using HTML & JavaScript and uses the W3C Web Components standard such that they run natively in browsers, are lightweight and provide optimal performance. Lightning Web Components and Aura Components will not conflict with each other and can coexist and interoperate on the same page.
In order to build a Lightning Web Component, an external code editor is required, Lightning web components cannot be developed in the Developer Console. Lightning Web Components cannot contain Aura Components, but Aura Components can contain Lightning Web Components.
Given the code below, what will be the result? Choose 1 answer.
Integer i = 0;
String str = '';
for (Integer x = 0; x < 10; x++) {
str = 'sampleStr';
i = x;
}
if (i > 9) {
system.debug(str + ' A = ' + i);
} else if (i < 9) {
system.debug(str + ' B = ' + i);
} else {
system.debug(str + ' C = ' + i);
}
A. str B = 9
B. sampleStr A = 10
C. sampleStr C = 9
D. str B = 10
C. sampleStr C = 9
The for loop will iterate the code block until the value of x = 9. The value of x, which is 9, will be assigned to variable [i]. So variable [int] will satisfy the third condition. Expected output will be: sampleStr C = 9
Which of the following are true regarding list or set iteration for loops? Choose 3 answers.
A. List or set iteration for loops are not usable when one needs to iterate over multiple collections in parallel.
B. The standard syntax for list or set iteration for loops is: for(Type variable : list_or_set) { code_block }
C. The variable may or may not be of the same primitive or sObject type as list_or_set.
D. A list or set iteration for loop can be used when elements in a list or array need to be added or removed while iterating it.
E. During execution, the variable is assigned to each element in list_or_set, and runs the code_block for each value.
A. List or set iteration for loops are not usable when one needs to iterate over multiple collections in parallel.
B. The standard syntax for list or set iteration for loops is: for(Type variable : list_or_set) { code_block }
E. During execution, the variable is assigned to each element in list_or_set, and runs the code_block for each value.
The variable must be of the same type as the collection. Elements in a list or set cannot be added or removed within the code block of a for loop that iterates through it.
Cosmic Electronics uses Salesforce to manage opportunities. The company also uses an external order management application to manage orders. Sales users use the application to create orders manually after winning sales deals. But the sales director would like to automate this process. When an opportunity is won, the external application should receive a notification and create the associated order record automatically based on the details in the notification. A developer of the company has decided to use a platform event for this use case. Which of the following should be utilized when using a platform event to meet this requirement? Choose 3 answers.
A. Custom object definition with custom fields
B. CometD client that subscribes to the platform event channel
C. Platform event definition with custom fields
D. Apex trigger or process that publishes an event message
E. Apex class that subscribes to the platform event channel
B. CometD client that subscribes to the platform event channel
C. Platform event definition with custom fields
D. Apex trigger or process that publishes an event message
In order to meet this requirement, a platform event can be defined and custom fields can be added to it. The custom fields can contain data that should be sent in the event message. Salesforce can publish the platform event message and the external application can act as the subscriber.
An Apex trigger or process on the Opportunity object can be used to publish a platform event message automatically when the stage of an opportunity changes to 'Closed Won'. When using an Apex trigger, the event message can be published using the EventBus.publish() method. The external application can subscribe to the event channel using a custom CometD client or EMP Connector and receive event messages.
When a message is received, the external application can create an order automatically based on the field values in the message.
A custom object definition is not required to set up a platform event. An Apex class is also not required to subscribe to the platform event from the external system.
Unit tests need to be created for testing new functionality added to an Apex class that is used as a controller of an account management tool. If the variable 'a' represents an Account record in the code snippet of a unit test below, which of the following options represents code that should be used to replace the placeholder comments? Choose 2 answers.
a.addError('Site', 'Site is not accessible!');
//Add code to assert that an error was added to the account instance
//Add code to retrieve any errors added to the account instance System.assertEquals(errors.size(), 1);
A.System.assertEquals(a.hasErrors(), true);
B.List<Database.Error> errors = a.getErrors();
C.System.assertEquals(a.containsErrors(), true);
D.List<Database.Error> errors = a.errors();
"A.System.assertEquals(a.hasErrors(), true);
B.List<Database.Error> errors = a.getErrors();
The sObject class provides the error methods addError(), hasErrors(), and getErrors() that can be used for testing Apex code. The addError() method can be used to dynamically add errors to fields of an sObject associated with the specified field such as the 'Site' field in the code snippet above. The hasErrors() method returns true if an object instance contains any errors. The getErrors() method is used to retrieve a list of errors (List<Database.Error>) that are added to an object instance.
The resulting code should be as follows:
a.addError('Site', 'Site is not accessible!'); System.assertEquals(a.hasErrors(), true); List<Database.Error> errors = a.getErrors(); System.assertEquals(errors.size(), 1);
The errors() and containsErrors() methods do not exist."