4. Platform Developer 1: Logic and Process Automation Part 2

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

String is one of the primitive data types in Salesforce. Given the following options, what is a valid value that a string data type variable can contain? A. 'Salesforce' B. TRUE C. "Salesforce" D. 3.14159

A. 'Salesforce'

A developer is required to access Opportunity records on a Visualforce page without using a custom controller. How can the developer satisfy this requirement? A. <apex:page standardController="Opportunity" recordSetVar="opportunities"> B. <apex:page controller="Opportunity" recordSetVar="opportunities"> C. <apex:page standardController="Opportunity" getAllRecordsVar="opportunities"> D. <apex:page controller="Opportunity" recordListVar="opportunities">

A. <apex:page standardController="Opportunity" recordSetVar="opportunities">

Which of the following statements are true about controller extensions? Choose 3 answers. A. A controller extension is an Apex class that extends the functionality of a standard or custom controller. B. Only one controller extension can be defined for a single page. C. The extension is associated with the page using the 'extensions' attribute of the <apex:page> component. D. If an extension works in conjunction with a standard controller, the standard controller methods will also be available.

A. A controller extension is an Apex class that extends the functionality of a standard or custom controller. C. The extension is associated with the page using the 'extensions' attribute of the <apex:page> component. D. If an extension works in conjunction with a standard controller, the standard controller methods will also be available.

When writing an Apex Trigger, what should a developer keep in mind? Choose 2 answers. A. A single Apex Trigger is all you need for each object. B. An Apex Trigger should be logic-less and delegate the logic responsibilities to a handler class. C. An Apex Trigger should not cause another trigger to be fired D. An Apex Trigger should use @future annotation in performing DML operations.

A. A single Apex Trigger is all you need for each object. B. An Apex Trigger should be logic-less and delegate the logic responsibilities to a handler class.

A developer imported 4,000 account records into Salesforce and wishes to verify if these were created correctly. There are already over 60,000 accounts already existing in the system. The developer implemented Apex code to check the records created. What is the correct pattern to follow? A. Add criteria to SOQL Select statements to filter out unnecessary records. B. DML should be used on one instance/record at a time C. SOQL statements should be placed inside loops when matching to ensure updated results for every iteration. D. Use the [with sharing] keyword to ensure the query will find the appropriate records.

A. Add criteria to SOQL Select statements to filter out unnecessary records.

When a trigger fires, it can process multiple records so all triggers should be written to accommodate bulk transactions. Which of the following are examples of single record and bulk transactions? Choose 3 answers. A. Data import B. Bulk Force.com API calls C. Lightning Events D. Mass actions E. Visualforce Actions

A. Data import B. Bulk Force.com API calls D. Mass actions

What will happen if a governor limit is hit from an Apex class that was called from an Apex controller class of a VisualForce page? A. It will rollback all changes made up to the error. B. It will save all changes made before savepoint. C. It will save all changes made from the Apex controller class. D. An exception will be thrown

A. It will rollback all changes made up to the error. D. An exception will be thrown

What is true in the code below? try { String sampleStr; if (sampleStr.contains('abcd')) { system.debug('Hello World'); } } catch(DmlException e) { System.debug('DmlException: ' + e.getMessage()); } catch(SObjectException e) { System.debug('SObjectException: ' + e.getMessage()); } catch(ListException e) { System.debug('ListException: ' + e.getMessage()); } catch(Exception e) { System.debug('Exception: ' + e.getMessage()); } A. Line 3 will cause a NullPointerException and the last catch block (Line 12), as a generic Exception, will handle it. B. No catch blocks (LIne 6,8,10) match the exception criteria, therefore the error is still unhandled. C. All catch blocks (Line 6,8,10) will be executed even if only one matches the exception criteria. D. The try-block will be successfully executed with no errors.

A. Line 3 will cause a NullPointerException and the last catch block (Line 12), as a generic Exception, will handle it.

Given the following options, what data type should the developer use to store queried records via SOQL? A. List B. Group C. Enum D. Container

A. List

What is true regarding a future method? Choose 2 answers. A. Methods that are annotated with @future identify methods that are executed asynchronously B. Methods that are annotated with @future identify methods that are executed synchronously C. A method annotated with future can call another method that also has the future annotation D. Methods annotated with future can only return a void type

A. Methods that are annotated with @future identify methods that are executed asynchronously D. Methods annotated with future can only return a void type

A developer created a trigger with the following code below: trigger lineItemPerInvoice on Invoice_Statement__c (before insert, before update) { for(Invoice_Statement__c inv : trigger.new) { List<LineItem__c> liList = [SELECT Id, Units_Sold__c FROM LineItem__c WHERE Invoice_Statement__c IN: inv]; for(LineItem__c li : liList) { //do logic here } } } What is true about the code snippet? Choose 3 answers. A. The SOQL query performed inside the loop retrieves the Line item for each invoice statement. B. The trigger has only one SOQL query performed and is still within the governor limits C. When updating more than 100 Invoice statement records, it will throw a run time exception for exceeding the governor limit for SOQL queries. D. The trigger bypasses the problem of having the SOQL query called for each item. E. The trigger shows an example of inefficient querying of child items.

A. The SOQL query performed inside the loop retrieves the Line item for each invoice statement. C. When updating more than 100 Invoice statement records, it will throw a run time exception for exceeding the governor limit for SOQL queries. E. The trigger shows an example of inefficient querying of child items.

A developer needs to implement apex code in a multi-tenant platform. Choose the appropriate pattern to follow. A. To prevent exceeding governor limits, select the fewest fields and filter records in SOQL statements. B. To avoid data concurrency issues, DML operations should only be used on one record at a time. C. To minimize deployment errors, Apex code is developed in a different environment. D. To prevent access from other server tenants, the "with sharing" keyword is used in Apex classes.

A. To prevent exceeding governor limits, select the fewest fields and filter records in SOQL statements.

A developer can develop code to insert records that will allow successful inserts and will record errors for unsuccessful records. This is called partial processing. However, this method will not throw an exception. How should a developer handle the possible exceptions? A. Use Database.SaveResult Class B. Use Database.ErrorResult Class C. Use Database.SuccessResult Class D. Use Database.EachResult Class

A. Use Database.SaveResult Class

A junior developer is frequently experiencing governor limit errors when running an Apex Trigger. As a Senior developer, which of the following are best practices that you could advise? There are 2 correct answers. A. Use collections (e.g maps, lists) to capture query results. B. Use a handler class for multiple triggers scenarios C. Use lists of sObjects in DML transactions D. Use only SOQL queries within for loops

A. Use collections (e.g maps, lists) to capture query results. C. Use lists of sObjects in DML transactions

What are valid use cases for using a controller extension in a Visualforce page? Choose 3 answers. A. You need to override the edit action of the standard controller B. A new action needs to be added C. Functionality of the standard controller should be replaced D. You want to select if the page runs in system mode

A. You need to override the edit action of the standard controller B. A new action needs to be added D. You want to select if the page runs in system mode

Which of the following code snippets are examples of statements that should not be included within a looping statement? Choose 2 answers. A. insert accountList; B. System.debug('The following account has been updated' + 'acc.Id '); C. Opportunity getOpp = [SELECT Id, AccountId FROM Opportunity WHERE AccountId =: acc.Id]; D. if(acc.NumberOfEmployees > 5000){

A. insert accountList; C. Opportunity getOpp = [SELECT Id, AccountId FROM Opportunity WHERE AccountId =: acc.Id];

What is the correct syntax for writing an Apex Trigger? A. trigger TriggerName on ObjectName (trigger_events) { code_block; } B. trigger TriggerName on TriggerEvents (ObjectName) { code_block; } C. trigger ObjectName on TriggerName (trigger_events) { code_block; } D. trigger ObjectName on trigger_events (TriggerName) { code_block; }

A. trigger TriggerName on ObjectName (trigger_events) { code_block; }

Which of the following is the correct syntax for a try-catch-finally block? A. try{ *code here* } catch (Exception e) { *code here* } finally { *code here* } B. catch { *code here* } try (Exception e) { *code here* } finally { *code here* } C. catch { *code here* } finally (Exception e) { *code here* } try { *code here* } D. finally{ *code here* } catch (Exception e) { *code here* } try { *code here* }

A. try{ *code here* } catch (Exception e) { *code here* } finally { *code here* }

What are valid use cases for using a custom controller in a Visualforce page? Choose 2 answers. A. A Visualforce page needs to add new actions to a standard controller B. A Visualforce page should run in system mode C. A Visualforce page should replace the functionality of the standard controller D. A Visualforce page should override the save action of the standard controller

B. A Visualforce page should run in system mode C. A Visualforce page should replace the functionality of the standard controller

What does Trigger.new contain? A. A list of new records and is available only in insert triggers B. A list of new versions of records and is available in insert, update and undelete triggers C. A set of new versions of records available in insert and update triggers D. A map of sObject ids and records that are new or modified and available in insert and update triggers

B. A list of new versions of records and is available in insert, update and undelete triggers

A developer is trying to create a trigger that will set the record type of an Invoice record, prior to insertion, based on the value of the Industry picklist that is selected. What trigger event should the developer use? A. After Insert B. Before Insert C. After Update D. Before Delete

B. Before Insert

What is the order of execution when a record is saved? A. Before Triggers, Validation Rules, Workflow Rules, After Triggers, Assignment Rules, Commit B. Before Triggers, Validation Rules, Duplicate Rules, After Triggers, Assignment Rules, Workflow Rules, Commit C. Validation Rules, Before Triggers, Workflow Rules, After Triggers, Workflow Rules, Assignment Rules, Commit D. Workflow Rules, Validation Rules, Before Triggers, After Triggers, Assignment Rules, Commit

B. Before Triggers, Validation Rules, Duplicate Rules, After Triggers, Assignment Rules, Workflow Rules, Commit

What standard controller action that aborts an edit operation in which after this operation is finished, the user will be returned to the page where originally invoked the edit? A. Break B. Cancel C. Revoke D. Stop

B. Cancel

Which of the following is not a valid Apex data type? Choose 2 answers. A. Blob B. Currency C. ID D. Text E. Enum

B. Currency D. Text

Given the following Visualforce page snippet, the following statements are true except: <apex:page standardController="Lead" extensions="LeadExtA, LeadExtB, LeadExtC "> <apex:outputText value="{!display}" /> </apex:page> A. The extension controllers are LeadExtA, LeadExtB, LeadExtC. B. If a method is declared across all extensions, the LeadExtC will override all methods. C. LeadExtA, LeadExtB or LeadExtC cannot exist by itself without a standard controller Lead. D. It is possible to have multiple extensions and extensions can be reused on different controllers.

B. If a method is declared across all extensions, the LeadExtC will override all methods.

A developer implemented two workflow field updates. Field update on Rule A triggers Rule B and the other way around. What will happen? A. This will not happen as field updates implicitly prohibit recursion. B. It will cause a loop and the organization will exceed its limit for workflow time triggers per hour. C. A field update exception will occur and will be displayed for the current user. D. The workflow reevaluation will automatically be suspended.

B. It will cause a loop and the organization will exceed its limit for workflow time triggers per hour.

The following actions can be performed in the Before Update trigger except? Choose 2 answers. A. Change its own field values using trigger.new. B. Modifying trigger.old values. C. Create a validation before accepting own field changes. D. Delete trigger.new values to avoid changes.

B. Modifying trigger.old values. D. Delete trigger.new values to avoid changes.

The following statements are true about apex generic exceptions and built-in exceptions except? A. The generic Exception catches all exception types. B. NullPointerException occurs when there is a problem with unauthorized access, such as trying to access an sObject when the current user does not have access to it. C. QueryException occurs when there is a problem with SOQL queries. D. NoAccessException occurs when there is a problem with unauthorized access such as trying to access an sObject that the current user does not have access to.

B. NullPointerException occurs when there is a problem with unauthorized access, such as trying to access an sObject when the current user does not have access to it.

A developer needs to get all IDs of related Accounts on all of the Contact records. What collection data type should the developer use to avoid having duplicate IDs? A. List B. Set C. Map D. Group

B. Set

If a developer is required to create a page that will show and add actions on a set of records, what controller should a developer use? A. Standard Controller B. Standard List Controller C. Custom Controller D. Lightning Bundle Controller

B. Standard List Controller

A custom object has a workflow that updates a field after a criteria is met and also has an Apex trigger defined that will fire on update. What will happen when a user updates a record? A. An exception will be thrown due to a conflict between the two B. The Apex Trigger will be fired multiple times C. Both will be fired only once D. The Apex Trigger will be fired first, voiding the Workflow Rule due to the order of execution

B. The Apex Trigger will be fired multiple times

What is true about Custom Exceptions? There are 3 correct answers. A. Built-in and custom Apex exceptions are roughly the same in throwing and catching exceptions. B. They are capable of specifying detailed error messages and have additional custom error handling in catch blocks. C. They are built by extending the built-in Exception class and should end with the word Exception. D. They are primarily useful if the method is called by another method and the exception handling is transferred to the other method. E. They are not capable of re-throwing a caught exception.

B. They are capable of specifying detailed error messages and have additional custom error handling in catch blocks. C. They are built by extending the built-in Exception class and should end with the word Exception. D. They are primarily useful if the method is called by another method and the exception handling is transferred to the other method.

When a developer designs SOQL relationship queries, there are several boundaries to consider. The following statements are true except? Choose 2 answers A. A relationship between objects to create a join in SOQL is a prerequisite. B. Up to five levels of parent-to-child relationship can be specified in a query. C. For a child-to-parent relationship, only one level can be specified in a query. D. Each SOQL query can have up to four joins across external objects and other types of objects.

B. Up to five levels of parent-to-child relationship can be specified in a query. C. For a child-to-parent relationship, only one level can be specified in a query.

What exception method should the developer use to know the error message that displays for the user? A. getCause B. getMessage C. getStackTraceString D. getTypeName

B. getMessage

What trigger context variable will return a map of IDs to the old versions of the sObject records? A. newMap B. oldMap C. updateMap D. insertMap

B. oldMap

What attribute should a developer use to associate a page with the standard controller for a custom object? A. customController B. standardController C. visualController D. controller

B. standardController

Which of the following ways cannot be used to throw a custom exception? A. throw new customExceptionName(); B. throw new customExceptionName().addError('Error Message Here') C. throw new customExceptionName('Error Message Here'); D. throw new customExceptionName(e);

B. throw new customExceptionName().addError('Error Message Here')

On what event should the trigger below be fired? Trigger createCallingCard on Contact (EVENT) { List<CallingCard__c> cardList = new List<CallingCard__c>(); for (Contact con : Trigger.new) { CallingCard__c newCard = new CallingCard__c(); newCard.Name = con.Name; newCard.Phone = con.Phone; newCard.Address = con.Address; newCard.relatedContact__c = con.Id; cardList.add(newCard); } insert cardList; } A. After Update B. Before Delete C. After Insert D. Before Insert

C. After Insert

Which of the following statements about defining triggers is NOT true? A. Trigger code is stored as metadata under the object which they are associated with. B. For the Attachment, ContentDocument and Note standard objects, you cannot create a trigger in the Salesforce user interface. C. Apex Triggers are always active and cannot be turned off. D. A developer can specify the version of Apex and API which can be used with the Trigger.

C. Apex Triggers are always active and cannot be turned off.

A developer needs to create a trigger that will throw an error whenever the user tries to delete a contact which is not associated to an account. What trigger event should the developer use? A. Before Insert B. After Insert C. Before Delete D. After Delete

C. Before Delete

Which of the following statements is true about defining getter methods? A. The [get] method is used to pass data from Visualforce page to Apex controller. B. Use the name of the getter method in an expression to display the results of a getter method in a page. C. Every value that is calculated by a controller and displayed in a page must have a corresponding getter method D. Getter methods are suggested to include logic that increments a variable, write a log message, or add a new record to the database.

C. Every value that is calculated by a controller and displayed in a page must have a corresponding getter method

Which of the following statements about setter methods is false? A. The [set] method is used to pass values from Visualforce page to the controller. B. Setter methods are executed prior to action methods. C. It is necessary to include a setter method to pass values into a controller. D. Setter methods must always be named setVariable.

C. It is necessary to include a setter method to pass values into a controller.

The following code snippet fails during bulk data load: for(Contact con : Trigger.new) { if(con.PostalCode != null) { List<State__c> stateList = [SELECT Id, Postal__c From State__c WHERE Postal__c =: con.PostalCode]; if (stateList.size()>0) { con.State__c = stateList[0].Id; } } } What is the root cause? A. Line 1: Variable 'con' is not declared. B. Line 2: Condition is invalid and will always be null. C. Line 3: SOQL query is located inside of the for loop code. D. Line 4: No update DML over list of Contacts

C. Line 3: SOQL query is located inside of the for loop code.

A developer needs to write a trigger on the [Survey] custom object. This trigger will use the email address on the [Survey] record and look for a matching email address on the existing contact records. If a matching email address is found, then the [Survey] record [Name of Contact] field should be populated with the name of the contact found. What is the best collection data type to use when storing contact records? A. List B. Set C. Map D. Group

C. Map

What will be the result of running the following code? for (Integer x = 0; x < 200; x++) { Account newAccount = new Account ( Name= 'MyAccount-' + x); try { insert newAccount; System.debug(Limits.getDMLStatements()); } catch(exception ex) { System.Debug('Caught Exception'); System.Debug(ex); } } insert new Account(Name='MyAccount-last'); A. A limit exception will be caught and one account will be inserted B. 150 accounts will be inserted C. No accounts will be inserted D. 201 accounts will be inserted

C. No accounts will be inserted

All of the following are action methods that are supported by standard controllers except? A. Quicksave B. Delete C. Select D. Cancel

C. Select

The following statements are true about avoiding SOQL queries inside For Loops, as Apex best coding practices, except? A. By moving queries outside of for loops, your code will run faster, and is less likely to exceed governor limits. B. When queries are placed inside a for loop, a query is executed on each iteration and governor limit is easily reached. C. The code below is an example of improper SOQL limit utilization: for(Account a : [Select Id, Name From Account Limit 1000]){ D. If a developer needs to query, query once, retrieve all the necessary data in a single query, then iterate over the results.

C. The code below is an example of improper SOQL limit utilization: for(Account a : [Select Id, Name From Account Limit 1000]){

Error messages are not displaying when errors are caught in the following code. What is the reason for this?: try{ //some logic here } catch (Exception e) { ApexPages.Message errMsg= new ApexPages.Message(ApexPages.Severity.FATAL,e.getMessage()); ApexPages.addMessage(errMsg); } A. Incorrect syntax for ApexPages on the controller side. B. The whole page is refreshing and at that point loses the message C. The message component is not added to the page - <apex:pageMessages/≶ D. The entity that causes the error is on the reRender attribute which will cause the error to not show.

C. The message component is not added to the page - <apex:pageMessages/≶

A developer is required to override the standard Opportunity view button using a Visualforce page. What should the developer do? A. Use the StandardListController B. Use a custom controller and replicate the opportunity detail page C. Use the Opportunity StandardController D. Use a controller extension

C. Use the Opportunity StandardController

What method displays a custom error message on a particular record and prevents any DML operations thereafter? A. addError(errMsg, escape) B. throwError(errMsg) C. addError(errMsg) D. clear(errMsg)

C. addError(errMsg)

What trigger context variable will return true if the current context for the Apex code is a trigger, not a Visualforce page, a Web service, or an executeanonymous() API call? A. oldMap B. isUndelete C. isExecuting D. isUpdate

C. isExecuting

A developer has created the following trigger to update the description of existing Contract records: List<Contract> getContracts = new List<Contract>(); for(Opportunity opp: (List<Opportunity>) Trigger.New) { Contract con = [SELECT Id FROM Contract WHERE Id =: opp.ContractId]; con.Description = 'This is the contract for Opportunity ' + opp.Name; getContracts.add(con); } update getContracts; How many Contract records will be updated when a developer loads 2000 Opportunity records? A. 2000 B. 100 C. 1 D. 0

D. 0

A developer is considering using a standard controller on a Visualforce page. Which of the following is not a valid consideration about standard controllers? A. To associate a standard controller with a Visualforce page, use the standardController attribute on the <apex:page> tag and assign it the name of any Salesforce object that can be queried using the Force.com API. B. The standard controller provides a set of standard actions, such as create, edit, save, and delete, that you can add to your pages using standard user interface elements such as buttons and links. C. Every standard controller includes a getter method that returns the record specified by the id query string parameter in the page URL. D. A Standard controller can retrieve a list of items to be displayed, make a callout to an external web service, validate and insert data

D. A Standard controller can retrieve a list of items to be displayed, make a callout to an external web service, validate and insert data

A developer has written the following code to do a SOSL search: FIND {New York}. What will be returned? A. A list of Contacts that match the search term B. A map of Accounts or Contacts that match the search term C. A map of sObjects that match the search term D. A list of lists of sObjects that match the search term

D. A list of lists of sObjects that match the search term

A developer has the following requirement: Every time a record on Contact with isPrimaryContact field set to true is deleted, update the field hasPrimaryContact to false of its related Account. The developer should create a trigger in what event? A. Before Update B. Before Delete C. After Update D. After Delete

D. After Delete

As per the order of execution, when will an email created from a workflow email alert be sent? A. When all before triggers are executed. B. Before entitlement rules execution. C. After workflow rule execution. D. After all DML operations are committed to the database.

D. After all DML operations are committed to the database.

A developer is required to create a trigger that every time the Type field on Request object is updated, the Owner field should be changed as well, either to a User or Queue. What trigger event should the developer use? A. After Merge B. Before Delete C. After Update D. Before Update

D. Before Update

Which of the following is a standard controller action that aborts an edit operation? A. Save B. Close C. Delete D. Cancel

D. Cancel

What will happen when the following code is executed? trigger CaseTrigger on Case (after insert) { List<Case> casesToInsert = new List<Case>(); for (Case parent: Trigger.new) { Case child = new Case(); child.ParentId = parent.Id; child.Subject = parent.Subject + ' Child'; casesToInsert.add(child); } insert casesToInsert; } A. No child cases will be created. B. Child cases will be inserted for each Parent case. C. The trigger will throw an exception because it is not bulkified. D. The trigger will be recursively called which will result in an infinite loop and will eventually throw an exception.

D. The trigger will be recursively called which will result in an infinite loop and will eventually throw an exception.

When catching exceptions the default notification actions in uncaught exceptions will be lost so developers are expected to formulate their own. The following options are ways in which a developer can handle the exceptions and notify users except? A. Sending an email that may add to the catch-block of a try-catch. B. Adding a @future method to create a record on a custom object that could catch the error details. C. Using .addError method on errors that may occur in DML on Apex Triggers. D. Using ApexPages.message class to create an error message for display on a Visualforce page. E. None of the above.

E. None of the above.


संबंधित स्टडी सेट्स

mental health quiz 3 (chp: 11, 12, 20, 21, 10, 13, 22, 30, 16, & 19 + pharm chp: 7 & 8)

View Set

Med Surg: Chapter 51: Nursing Assessment: Integumentary Function: PREPU

View Set

PLT Praxis (5622) M.C. Practice Questions

View Set

Principles of Computer: Chapter 6

View Set

CH 4. Life insurance policies- types of policies

View Set

SS.7.C.3.1 Compare different forms of government (direct democracy, representative democracy, socialism, communism, monarchy, oligarchy, autocracy).

View Set

Inductive and Deductive Reasoning

View Set