CRT-450 Practice Test practice questions, page 3 of 18, with answer review and explanations.
Question 11
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 Visualforce page that calculates the total number of hours for a timecard and displays it on the page
A Roll-Up Summary field on the Timecard Object that calculates the total hours from timecard entries for that timecard
A Process Builder process that updates a field on the timecard when a timecard entry is created
An Apex trigger that uses an Aggregate Query to calculate the hours for a given timecard and stores it in a custom field
Question 12
A developer encounters APEX heap limit errors in a trigger. Which two methods should the developer use to avoid this error? (Choose two.)
Use the transient keyword when declaring variables.
Query and store fields from the related object in a collection when updating related objects.
Remove or set collections to null after use.
Use SOQL for loops instead of assigning large queries results to a single collection and looping through the collection.
Question 13
Which approach should be used to provide test data for a test class?
Query for existing records in the database.
Execute anonymous code blocks that create data.
Use a test data factory class to create test data.
Access data in @TestVisible class variables.
Question 14
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?
Build a OpportunityLineItem trigger that adds a PriceBookEntry record.
Build an OpportunityLineItem trigger to add an OpportunityLineItem record.
Build an Opportunity trigger that adds a PriceBookEntry record.
Build an Opportunity trigger that adds an OpportunityLineItem record.
Question 15
Which two statements are true about using the @testSetup annotation in an Apex test class? (Choose two.)
The @testSetup annotation cannot be used when the @isTest(SeeAllData=True) annotation is used.
Test data is inserted once for all test methods in a class.
Records created in the @testSetup method cannot be updates in individual test methods.
The @testSetup method is automatically executed before each test method in the test class is executed.