Salesforce Certified Platform Developer II Part 3
Question #: 81
Topic #: 1
A developer has created a solution using the SOAP API for authenticating Communities users.
What is needed when issuing the login() Call? (Choose two.)
- Organization Id
B. Session Id
C. Username and Password
D. Security Token
Selected Answer: CD
Question #: 82
Topic #: 1
When developing a Visualforce page that will be used by a global organization that does business in many languages and many currencies, which feature should be used? (Choose three.)
- Custom Labels
B. convertCurrency()
C. Global Labels
D. Translation Workbenc
E. getLocalCurrency()
Selected Answer: D
Question #: 83
Topic #: 1
A developer needs test data for Apex test classes.
What can the developer use to provide test data to the test methods? (Choose two.)
- List Is = Test.loadData (Lead.sObjectType, ‘myTestLeads’);
B. myDataFactory.createTestRecords (10)
C. Database.createTestRecords (10)
D. List Is = Test.loadDat (Lead.sObjectType, $Resource + ‘myTestLeads’);
Selected Answer: AB
Question #: 84
Topic #: 1
[FIND ‘map’ IN ALL FIELDS RETURNING Account (Id, Name), Contact, Opportunity, Lead]
What is a valid return type for the following SOSL query?
- List
B. List>
C. List
D. List
Selected Answer: B
Question #: 85
Topic #: 1
What level can a hierarchy custom setting be defined for? (Choose three.)
- Users
B. Groups
C. Profiles
D. Roles
E. Organization
Selected Answer: ACE
Question #: 86
Topic #: 1
A developer has created a Visualforce page that uses a third-party JavaScript framework. The developer has decided to supply data to the JavaScript functions using JavaScript Remoting for Apex Controllers.
What is the correct syntax to declare a remote method in Apex? (Choose two.)
- @RemoteAction global static String getTable()
B. @RemoteAction global String getTable()
C. @RemoteAction public static String getTable()
D. @RemoteObject global static String getTable()
Selected Answer: AC
Question #: 87
Topic #: 1
Which API can be used to execute unit tests? (Choose three.)
- Streaming API
B. Test API
C. Tooling API
D. SOAP API
E. Metadata API
Selected Answer: CDE
Question #: 88
Topic #: 1
Which statement is true about using ConnectApi namespace (also called Chatter in Apex)? (Choose two.)
- Chatter in Apex methods honor the ‘with sharing’ and ‘without sharing’ keywords
B. Chatter in Apex operations are synchronous, and they occur immediately
C. Chatter in Apex methods do not run in system mode; they run in the context of the current user
D. Many test methods related to Chatter in Apex require the IsTest (SeeAllData=true) annotation
Selected Answer: CD
Question #: 89
Topic #: 1
A developer receives a LimitException: Too many query rows: 50001 error when running code.
What debugging approach using the Developer Console provides the fastest and most accurate mechanism to identify a specific component that may be returning an unexpected number of rows?
- Count the number of Row Limit warning messages in the Debug Logs
B. Add System.debug(System.getQueryRows()) to the code to track SOQL usage
C. Filter the Debug Log on SOQL_EXECUTE_END statements to track the results of each SOQL Query
D. Use the Execution Overview to see the number of rows returned by each Executed Unit
Selected Answer: D
Question #: 90
Topic #: 1
A developer is writing a Visualforce page to display a list of all of the checkbox fields found on a custom object.
What is the recommended mechanism the developer should use to accomplish this?
- Schema Class
B. Apex API
C. Schema Builder
D. Metadata API
Selected Answer: A
Question #: 91
Topic #: 1
A developer has created a Team Member sObject that has a Master-Detail relationship to a Project sObject and a Lookup relationship to the User sObject. The developer must ensure that a User listed on a Team Member record has Read-Write access to the parent Project record.
How can the developer accomplish this if the Project sObject has a Private sharing model and thousands of Project records?
- Create a Controller that uses the Without Sharing keyword
B. Create a Criteria-Based Sharing Rule on the Project sObject
C. Create a Team Member Trigger that inserts Project_Share records
D. Create a Project Sharing Rule that shares to the Team Member Group
Selected Answer: C
Question #: 92
Topic #: 1
1 Contact con = new Contact( LastName =’Smith’, Department = ‘Admin’)
2 insert con;
3 Contact insertedContact=[select Name from Contact where id=:con.Id];
4 Savepoint sp_admin = Database.setSavepoint();
5 con.Department = ‘HR’;
6 update con;
7 Database.rollback(sp_admin);
8 System.debug(Limits.getDmlStatements());
Given the following code, what value will be output in the logs by line #8?
- 5
B. 3
C. 4
D. 2
Selected Answer: C
Question #: 93
Topic #: 1
What is a recommended practice with regard to the Apex CPU limit? (Choose two.)
- Optimize SOQL query performance
B. Use Map collections to cache sObjects
C. Avoid nested Apex iterations
D. Reduce view state in Visualforce pages
Selected Answer: BC
Question #: 94
Topic #: 1
A developer wants to create a Visualforce page that allows a user to search for a given account by Name. If the account is found, the account details should be populated on screen. If no account is found, an error message should be displayed to the user.
How can this be accomplished? (Choose two.)
- Use the (apex: information) tag to display the error message
B. Use the ApexPages.addMessage() method to add the error message
C. Use the tag to display the error message
D. Use the account.addError() method to add the error message
Selected Answer: BC
Question #: 95
Topic #: 1
A developer has built a multi-page wizard using a single Custom Controller to query and update data. Users are complaining that the pages are loading slowly.
What will improve performance? (Choose three.)
- Reducing the view state
B. Using actionRegion and rerender
C. Turning off the standard stylesheet
D. Setting the Apex Page attribute cache=true
E. Using selective queries
Selected Answer: ABE
Question #: 96
Topic #: 1
A developer writes the following Apex trigger so that when a Case is closed, a single Survey record is created for that Case. The issue is that multiple Survey_c records are being created per Case. trigger CaseTrigger on Case (after insert, after update){ List createSurveys = new List(); for (Case c : trigger.new){ if (c.IsClosed && (trigger.isInsert II trigger.isUpdate && trigger.oldMap.get(c.Id).IsClosed == false)){ createSurveys.add(new Survey_c(Case_c = c.Id)); } } insert createSurveys; }
What could be the cause of this issue?
- A user is creating the record as Closed
B. A workflow rule is firing with a Create Task action
C. A workflow rule is firing with a Field Update action
D. A user is editing the record multiple times
Selected Answer: C
Question #: 97
Topic #: 1
What is a potential design issue with the following code?
trigger accountTrigger on Account (before update){ Boolean processOpportunity = false; List opptysClosedLost = new List() List IstAllOpp = [select StageName from Opportunity where accountId IN :Trigger.newMap.keySet()]; if(!IstAllOpp.isEmpty()) processOpportunity = true; while(processOpportunity)
{ for(opportunity o : IstAllOpp) if(o.StageName == ‘Closed – Lost’) opptysClosedLost.add(o); processOpportunity = false; if(!opptysClosedLost.isEmpty()) delete opptysClosedLost;
- SOQL could be avoided by creating a formula field for StageName in Account from the related Opportunity
B. The code will result in a System.LimitException : Too many script statements error
C. The code will result in a System.DmlException:Entity_is_Deleted error
D. The code will result in a System.LimitException: Apex CPU time limit exceeded error
Selected Answer: B
Question #: 98
Topic #: 1
The Contact object has a custom field called “Zone.” Its data type is “Text” and field length is 3.
What is the outcome after executing the following code snippet in the org?
List contactsToBeInserted=new List(); Contact contactInstance= new Contact(LastName=’Smith’,
Department=’Tech’, Zone_c=’IAD’); contactsToBeInserted.add(contactInstance); contactInstance= new Contact
(LastName=’Sm1th’, Department=’Tech’, Zone_c=’PITT’); contactsToBeInserted.add(contactInstance); Database.insert
(contactsToBeInserted,true);
- Both inserts succeed and the contact record that has the Zone value of ‘PI’I’I’ is set to NULL
B. A partial insert succeeds and the contact record that has the Zone value ‘IAD’ is inserted
C. Both inserts succeed and the contact record that has the Zone value of ‘PITT’ is truncated
D. An unhandled DML exception is thrown and no contact records are inserted
Selected Answer: D
Question #: 99
Topic #: 1
Which statement is true regarding the use of user input as part of a dynamic SOQL query?
- Free text input should not be allowed, to avoid SOQL injection
B. The String.format() method should be used to prevent injection
C. Quotes should be escaped to protect against SOQL injection
D. The string should be URL encoded by the input form to prevent errors
Selected Answer: C
Question #: 100
Topic #: 1
A developer has written the following method:
static void processList(List input){
Which code block can be used to call the method?
- processList (acc)
B. processList ([FIND ‘Acme” ‘RETURNING Account])
C. processList([SELECT Id, Name FROM sObject WHERE Type = ‘Account’])
D. for Account acc : [SELECT Id, Name FROM Account])
Selected Answer: A
Question #: 101
Topic #: 1
A developer needs to design a custom object that will be integrated into a back-end system.
What should the developer do to ensure good data quality and to ensure that data imports, integrations, and searches perform well? (Choose two.)
- Configure a custom field as unique
B. Configure a custom field as indexed
C. Configure a custom field as external ID
D. Configure a custom field as Salesforce ID
Selected Answer: AC
Question #: 102
Topic #: 1
A developer encounters an error that states that the Apex heap size is exceeded.
Which technique may reduce heap size?
- Add the transient keyword to the variable definition
B. Move the variable definition inside the scope of the function
C. Use static variables instead of instance variables
D. Use SOQL for loops instead of standard SOQL queries
Selected Answer: D
Question #: 103
Topic #: 1
A developer has a Debug method within a class, which is invoked hundreds of times.
What is the optimal functionality in the Developer Console to count the number of calls made to the method?
- The “Execution Log” Panel
B. The “Execution Stack” Panel
C. The “Executed Units” tab under the Execution Overview Panel
D. The “Execution Tree” tab under the Stack Tree Panel
Selected Answer: C
Question #: 104
Topic #: 1
What is a consideration when testing batch Apex? (Choose two.)
- Test methods must execute the batch with a scope size of less than 200 records
B. Test methods must call the batch execute() method once
C. Test methods must use the @isTest (SeeAllData=true) annotation
D. Test methods must run the batch between Test.startTest() and Test.stopTest()
Selected Answer: BD
Question #: 105
Topic #: 1
A custom field Exec_Count_c of type Number is created on an Account object. An account record with value of “1” for a: Exec_Count_c is saved. A workflow field update is defined on the Exec_Count_c field, to increment its value every time an account record is created or updated. The following trigger is defined on the account: trigger ExecOrderTrigger on Account (before insert, before update, after insert, after update){ for (Account accountInstance: Trigger.New){ if (Trigger . isBefore){ accountInstance Exec_Count_c += 1; } System. debug
(accountInstance.Exec_Count_c); } }
- 1, 2, 3, 3
B. 1, 2, 3, 4
C. 2, 2, 4, 4
D. 2, 2, 3, 3
Selected Answer: C
Question #: 106
Topic #: 1
A developer is building a Visualforce page that interacts with external services.
Which interface should the developer implement to test this functionality? (Choose two.)
- HTTPCalloutMock
B. HTTPRequestMock
C. HTTPResponseMock
D. StaticResourceCalloutMock
Selected Answer: AD
Question #: 107
Topic #: 1
A developer needs to create a Lightning page for entering Order Information. An error message should be displayed if the zip code entered as part of the Order’s shipping address is not numeric.
What is a recommended way for the error message be displayed to the end user?
- Use the apex:message tag to display errors
B. Use the aura:component tag to display errors
C. Use the ui:outputText tag to display errors
D. Use the ui:inputDefaultError tag to display errors
Selected Answer: D
Question #: 108
Topic #: 1
A developer is writing unit tests for the following method:
public static Boolean isFreezing(String celsiusTemp){ if(String.isNotBlank(celsiusTemp) && celsiusTemp.isNumeric())
{ return Decimal.valueof(celsiusTemp) <= 0; } return null; }
Which assertion would be used in a negative test case?
- System.assertEquals(true, isFreezing(null))
B. System.assertEquals (true, isFreezing(‘0’)
C. System.assertEquals(null, isFreezing(‘asdf’))
D. System.assertEquals(true, isFreezing(‘IOO’))
Selected Answer: B
Question #: 109
Topic #: 1
During the order of execution of a Visualforce page GET request, what happens after this step?
Evaluate constructors on controllers and extensions
- Evaluate constructors and expressions on custom components
B. Create view state if exists
C. Send the HTML response to the browser
D. Evaluate expressions, action attributes, and method calls
Selected Answer: A
Question #: 110
Topic #: 1
A developer needs to create a service that will process an email sent to it and create an account and contact using the contents of the email as data for the records.
How might a developer accomplish this requirement?
- Use the Apex Inbound Email Handler
B. Use the Fuel API with Email Data Extensions
C. Use Heroku Data Clips to Process Email
D. Use Auto-launched Flow and Process Builder
Selected Answer: A
Question #: 111
Topic #: 1
How can Apex be used with Visual Workflow?
- To set the version of a Flow being run
B. To start a Flow automatically
C. To add custom styling to a Flow
D. To control access to a Flow
Selected Answer: B
Question #: 112
Topic #: 1
An integration user makes a successful login() call via the SOAP API.
What can be used in the SOAP header to provide server authorization for subsequent API requests?
- Named Credentials
B. Session ID
C. OAuth access token
D. Security token
Selected Answer: B
Question #: 113
Topic #: 1
A customer has a single Visualforce page that allows each user to input up to 1500 sales forecasts and instantly view pivoted forecast calculations. Users are complaining that the page is loading slowly, and they are seeing error messages regarding heap and view state limits.
What are three recommendations to optimize page performance? (Choose three.)
- Segregate calculation functionality from input functionality
B. Specify the list of sales forecasts as transient
C. Implement pagination and reduce records per page
D. Create formula fields to compute pivoted forecast calculations
E. Use JavaScript Remoting instead of controller actions
Selected Answer: ABC
Question #: 114
Topic #: 1
A developer is creating unit tests for code that makes SOAP web service callouts. The developer needs to insert some test data as a part of the unit tests setup.
What are three actions to enable this functionality? (Choose three.)
- Surround the callout with Test.startTest(), Test.stopTest()
B. Surround the data insertion with Test.startTest(), Test.stopTest()
C. Implement the WebServiceMock interface
D. Update code to call Test.setMock()
E. Implement the HttpCalloutMock interface
Selected Answer: ACD
Question #: 115
Topic #: 1
Which of the follow be used together in DML operations (transaction)? (Choose two.)
- Account – AccountShare
B. Case – CaseComment
C. Opportunity – User
D. Account – Order
Selected Answer: BD
Question #: 116
Topic #: 1
A developer has generated Apex code from a WSDL for an external web service. The web service requires Basic authentication.
What code should the developer use to authenticate?
- Http.setHeader (‘Authorization’ , ‘Basic QthZGprjpchVulHNchFtZQ’)
B. stub.inputHttpHeaders_x.put(‘Authorization’ , ‘Basic QthZGprjpchVulHNchFtZQ’)
C. Http.setAuthentication(‘Basic QthZGprjpchVulHNchFtZQ’)
D. stub.authentication.put (‘Authorization’,’Basic QthZGprjpchVulHNchFtZQ’)
Selected Answer: B
Question #: 117
Topic #: 1
What is the correct syntax for calling a controller action from a Visualforce page and updating part of the page once the action is completed? (Choose two.)
A.
B.
C.
D.
Selected Answer: BD
Question #: 118
Topic #: 1
Employee_c is a Child object of Company_c. The Company_c object has an external Id field Company_Id_c.
How can a developer insert an Employee_c record linked to Company_c with a Company_Id_c of ‘999’?
- Employee_c emp = new Employee_c(Name=’Developer’); emp.Company_r = ‘999’ insert emp;
B. Employee_c emp = new Employee_c(Name=’Developer’); emp.Company_c = ‘999’ insert emp;
C. Employee_c emp = new Employee_c(Name=’Developer’); emp. Company_c = new Company_c(Company_Id_c=’999′) insert emp;
D. Employee_c emp = new Employee_c(Name=’Developer’); emp.Company_r = new Company_r(Company_Id_c=’999′) insert emp;
Selected Answer: C
Question #: 119
Topic #: 1
A developer must create a custom pagination solution. While users navigate through pages, if the data is changed from elsewhere, users should still see the cached results first accessed.
How can the developer meet these requirements?
- Use @Cache annotation
B. Use a StandardSetController
C. Use OFFSET in SOQL queries
D. Use OFFSET WITH CACHE in SOQL queries
Selected Answer: B
Question #: 120
Topic #: 1
Which use case is an appropriate fit for the @future asynchronous Apex method? (Choose two.)
- A developer has jobs that need larger query results than regular transactions allow
B. A developer needs to segregate DML operations and bypass the mixed save DML error
C. A developer has long-running jobs with large data volumes that need to be performed in batches
D. A developer has long-running methods and needs to prevent delaying an Apex transaction
Selected Answer: BD