Friday, May 3, 2019

Salesforce Certification PD1 Sample Questions 2019 Part 2


1. How can a developer set up a debug log on a specific user?

  Ask the user for access to their account credentials, log in as the user and debug the issue
  Create Apex code that logs code actions into a custom object
  It is not possible to setup debug logs for users other than yourself
  Set up a trace flag for the user, and define a logging level and time period for the race

2. A developer needs to create a baseline set of data (Accounts, Contacts, Products, Assets) for an entire suite of tests allowing them to test independent requirements various types of Salesforce Cases. Which approach can efficiently generate the required data for each unit test?

  Use @TestSetup with a void method
  Create a mock using the Stub API
  Create test data before Test.startTest() in the unit test
  Add @IsTest (see AllData=true) at the start of the unit test class

3. Requirements state that a child record be deleted when its parent is deleted, and a child can be moved to a different parent when necessary. Which type of relationship should be built between the parent and child objects in Schema builder to support these requirements?

  Lookup relationship from the child to the parent
  Child relationship
  Master-Detail relationship
  Lookup relationship from the parent to the child

4. Which two ways can a developer instantiate a PageReference in Apex?

  By using ApexPages.currentpage()
  By using an object standard set controller action
  By using an object standard controller action
  By using the PageReference.getURL() method

5. A Visualforce page uses the Contact standard controller. How can a developer display the Name from the parent Account record on the page?

  Use SOQL syntax to find the related Accounts Name field
  Use an additional standard controller for Accounts
  Use the {!contact.Account.Name} merge field syntax
  Use additional Apex logic within the controller to query for the Name field

6. A developer is creating a Visualforce page that allows users to create multiple Opportunities. The developer is asked to verify the current user's default Opportunity record type, and set certain default values based on the record type before inserting the record. How can the developer find the current user's default record type?

  Create the opportunity and check the opportunity.recordType before inserting, which will have the record ID of the current user's default record type
  Use Opportunity.sObjectType.getDescribe().getRecordTypeInfos() to get a list of record types, and iterate through them until isDefaultRecordTypeMapping is true
  Use the Schema.userInfo.Opportunity.getDefaultRecordType() method
  Query the Profile where the ID equals userInfo.getProfileID() and then use the profile.Opportunity.getDefaultRecordType() method

7. What is considered the primary purpose for creating Apex tests?

  To guarantee at least 50% of code is covered by unit tests before it is deployed
  To ensure every use case of the application is covered by a test
  To confirm every trigger is executed at least once
  To confirm all classes and triggers compile successfully

8. The sales team at Universal Containers would like to see a visual indicator appear on both Account and Opportunity page layouts to alert salespeople when an Account is late making payments or has entered the collections process. What can a developer implement to achieve this requirement without having to write custom code?

  Workflow Rule
  Quick Action
  Formula Field
  Roll-up Summary Field

9. Which two statements are true about Apex code executed in Anonymous Blocks?

  Successful DML operations are automatically committed
  The code runs with the permissions of the logged in user
  The code runs in system mode having access to all objects and fields
  The code runs with the permissions of the user specified in the runAs() statement

10. Which tag should a developer include when styling from external CSS is required in a Visualforce page?

  apex:includeScript
  apex:includeStyles
  apex:stylesheet
  apex:require

11. Given the code block:

      Integer x;
      for(x = 0; x<10; x+=2){
         if(x==8)
         break;
         if(x==10)
         break;
      }
      System.debug(x);

Which value will the system.debug statement display?

  8
  2
  10
  12

12. Which two roll-up summary field types are required to find the average of values on detail records in a Master-Detail relationship?

  Roll-up summary field of type SUM
  Roll-up summary field of type COUNT
  Roll-up summary field of type TOTAL
  Roll-up summary field of type NUM

13. How can a developer warn users of SOQL governor limit violations in a trigger?

  Use PageReference.setRedirect() to redirect the user to a custom Visualforce page before the number of SOQL queries exceeds the limit
  Use Limits.getQueries and display an error message before the number of SOQL queries exceeds the limit
  Use ApexMessage.Message() to display an error message after the number of SOQL queries exceeds the limit
  Use Messaging.SendEmail to continue the transaction and send an alert to the user after the number of SOQL

14. What is a benefit of using a trigger framework?

  Reduces trigger execution time
  Allows functional code to be tested by a test class
  Simplifies addition of context-specific logic
  Increases trigger governor limits

15. When a Task is created for a Contact, how can a developer prevent the task from being included on the Activity Timeline of the Contacts Account record?

  Create a Task trigger to set the Account field to NULL
  In Activity Settings, uncheck Roll up activities to a contact's primary account
  Use Process Builder to create a process to set the Task Account field to blank
  By default, tasks do not display on the Account Activity Timeline

16. A developer wants to use all of the functionality provided by the standard controller for an object, but needs to override the Save standard action in a controller extension. Which two are required in the controller extension class?

  Define the class with a constructor that takes an instance of Standard Controller as a parameter
  Create a method named Save with a return data type of PageReference
  Create a method that references this.supersave()
  Define the class with a constructor that creates a new instance of the Standard Controller class

17. An Apex transaction inserts 100 Account records and 2,000 Contact records before encountering a DML exception when attempting to insert 500 Opportunity records. The Account records are inserted by calling the database.insert() method with the allorNone argument set to false. The Contact and Opportunity records are inserted using the standalone insert statement. How many total records will be committed to the database in this transaction?

  100
  0
  2100
  2000

18. What is a key difference between a Master-Detail Relationship and a Lookup Relationship?

  A Master-Detail Relationship detail record inherits the sharing and security of its master record
  When a record of a master object in a Lookup Relationship is deleted, the detail records are also deleted
  A Lookup Relationship is a required field on an object
  When a record of a master object in a Master-Detail Relationship is deleted, the detail records are kept and not deleted

19. 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 Roll-Up Summary field on the Timecard Object that calculates the total hours from timecard entries for that timecard
  A Visualforce page that calculates the total number of hours for a timecard and displays it on the page
  An Apex trigger that uses an Aggregate Query to calculate the hours for a given timecard and stores it in a custom field
  A Process Builder process that updates a field on the timecard when a timecard entry is created

20. Which type of code represents the Model in the MVC architecture on the Force.com platform?

  A Controller Extension method that saves a list of Account records
  Custom JavaScript that processes a list of Account records
  A Controller Extension method that uses SOQL to query for a list of Account records
  A list of Account records returned from a Controller Extension method

21. For which example task should a developer use a trigger rather than a workflow rule?

  To set the Name field of an expense report record to Expense and the Date when it is saved
  To notify an external system that a record has been modified
  To set the primary Contact on an Account record when it is saved
  To send an email to a hiring manager when a candidate accepts a job offer

22. A developer wants to display all of the picklist entries for the Opportunity StageName field and all of the available record types for the Opportunity object on a Visualforce page. Which two actions should the developer perform to get the available picklist values and record types in the controlller? Choose 2 answers

  Use Schema.RecordTypeInfo returned by RecordType.sObjectType.getDescribe().getRecordTypeInfos()
  Use Schema.PicklistEntry returned by Opportunity.sObjectType.getDescribe().getPicklistValues()
  Use Schema.PicklistEntry returned by Opportunity.StageName.getDescribe().getPicklistValues()
  Use Schema.RecordTypeInfo returned by Opportunity.sObjectType.getDescribe().getRecordTypeInfos()

23. 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 2 answers.

  Create a master-detail relationship between the Rating and Employee objects
  Create a trigger on the Rating object that updates a field on the Employee object
  Create a lookup relationship between the Rating and Employee object
  Create a roll-up summary field on the Employee and use AVG to calculate the average rating score

24. which two SOSL searches will return records matching search criteria contained in any of the searchable text fields on an object? Choose 2 answers

  [FIND 'Acme*' IN ALL FIELDS RETURNING Account, Opportunity];
  [FIND 'Acme*' IN TEXT FIELDS RETURNING Account, Opportunity];
  [FIND 'Acme*' IN ANY FIELDS RETURNING Account, Opportunity];
  [FIND 'Acme*' RETURNING Account, Opportunity];

25. A developer needs to include a Visualforce page in the detail section of a page layout for the Account object, but does not see the page as an available option in the Page Layout Editor. Which attribute must the developer include in the tag to ensure the Visualforce page can be embedded in a page layout?

  action="AccountId"
  controller="Account"
  standardController="Account"
  extensions="AccountController"

26. Which two statements are true regarding formula fields? Choose 2 answers

  When concatenating fields, line breaks can be added to improve readability
  Fields that are referenced by a formula field can not be deleted until the formula is modified or deleted
  Formula fields may reference formula fields on the same object to a level of one deep
  When using the & operator to concatenate strings, the result is automatically truncated to fit the destination

27. The Account object has a custom formula field, Level_c, that is defined as a Formula (Number) with two decimal places. Which three are valid assignments? Choose 3 answers

  Long myLevel = acct.Level__c;
  Decimal myLevel = acct.Level__c;
  Integer myLevel = acct.Level__c;
  Object myLevel = acct.Level__c
  Double myLevel = acct.Level__c

28. A developer declared a class as follows.

      public class wysiwyg {

// properties and methods including DML

}
Which invocation of a class method will obey the organization-wide defaults and sharing settings for the running user in the Salesforce organization?

  An Apex trigger that invokes a helper method in this class
  A user on an external system that has an API call into Salesforce that invokes a method in this class
  A Visualforce page with an Apex controller that invokes a method in this class
  A developer using the Developer Console that invokes a method in this class from the execute anonymous window

29. A developer uses a Test Setup method to create an Account named 'Test'. The first test method deletes the Account record. What must be done in the second test method to use the Account?

  Call the Test Setup method at the start of the test
  The Account cannot be used in the second test method
  Use SELECT Id from Account where Name = 'Test'
  Restore the Account using an undelete statement

30. A developer needs to create a custom Visualforce button for the Opportunity object page layout that will cause a web service to be called and redirect the user to a new page when clicked. Which three attributes need to be defined in the tag of the Visualforce page to enable this functionality? Choose 3 answers

  standardController
  readOnly
  renderAs
  extensions
  action

31. A developer has the following class and trigger code.

      public class InsuranceRates {
public static final Decimal smokerCharge = 0.01;
}

trigger ContactTrigger on Contract(before insert){
InsuranceRates rates = new InsuranceRates();
Decimal baseCost=XXX;

}

Which code segment should a developer insert at the XXX to set the baseCost variable to the value of the class variable smokerCharge?

  InsuranceRates.smokerCharge
  rates.getSmokerCharge()
  ContactTrigger.InsuranceRates.smokerCharge
  rates.smokerCharge

32. Which statement is true about developing in a multi-tenant environment?

  Governor limits prevent Apex from impacting the performance of multiple tenants on the same instance
  Apex Sharing controls access to records from multiple tenants on the same instance
  Org-level data security controls which users can see data from multiple tenants on the same instance
  Global Apex classes can be referenced from multiple tenants on the same instance

33. Opportunity opp = (SELECT id, StageName FROM Opportunity LIMIT 1];
Given the code above, how can a developer get the label for the StageName field?

  Call "Opportunity.StageName.Label"
  Call "Opportunity.StageName.getDescribe().getLabel()"
  Call "opp.StageName.getDescribe().getLabel()"
  Call "opp.StageName.Label"


No comments:

Post a Comment