A developer creates a method in an Apex class and needs to ensure that errors are handled properly


Q1 A developer has following query
Contact c = [SELECT Id, FirstName, LastName, Email FROM Contact WHERE LastName = 'Smith'];
What does the query return if there is no Contact with the last name "Smith"?
A. A Contact with empty values.
B. A Contact initialized to null.
C. An empty List of Contacts.
D. An error that no rows are found.

Ans D. An error that no rows are found.

Q2 In the Lightning Component framework, which resource can be used to fire events?
Choose 2 answers
A. Visualforce controller options
B. Third-party web service code
C. Third-party Javascript code
D. Javascript controller actions

Ans C. Third-party Javascript code
    D. Javascript controller actions
Ref: https://developer.salesforce.com/docs/atlas.en- us.lightning.meta/lightning/events_external.htm

Q3 Which statement should a developer avoid using inside procedural loops?
Choose 2 answers
A. System.debug('Amount of CPU time (in ms) used so far: ' + Limits.getCpuTime());
B. update contactList;
C. List<Contact> contacts = [select id, salutation, firstname, lastname, email from Contact where account =a.id;
D. if(o.accountid== aid)

ANs B. update contactList;
    C. List<Contact> contacts = [select id, salutation, firstname, lastname, email from Contact where account =a.id;

Q4 which statement would a developer use when creating test data for products and pricebooks?
A.List objList = Test.loadData(Account.sObjectType,'myResource');
B.Pricebook pb= new Pricebook();
C.Id pricebookId=Test.getStandardPricebookId();
D.IsTest(SeeAllData=false);

Ans C.Id pricebookId=Test.getStandardPricebookId();

Q5 How can a developer determine from the DescribeSObjectResult if the current user will be able to create record an object in apex?
A By using the hasAccess() Method.
B. By using the isCreatable() method.
c. By using the isInsertable() method.
D. By using the canCreate() method.

Ans B. By using the isCreatable() method.
Ref: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_sobject_describe.htm

Q6 What is a valid statement about Apex classes and interfaces? Choose 2 answers
A. Exception classes must end with the word exception.
B. A class can have multiple levels of inner classes.
C. The default modifier for a class is private.
D. The default modifier for an interface is private.

Ans A. Exception classes must end with the word exception.
    C. The default modifier for a class is private.
Ref:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_defining.htm

Q7 What is an important consideration when in a multi-tenant environment?
A. Polyglot persistence provides support for a global, multilingual user base in multiple orgs on multiple instances
B. Governor limits prevent tenants from impacting performance in multiple orgs on the same instance
C. Unique domain names takes the place of namespace for code developed for multiple orgs for multiple instances
D.Org-wide data security determines whether other tenants can see data in multiple orgs on the same instance

Ans B. Governor Limits prevent tenants from impacting performance in multiple orgs on the same instance

Q8 What is the capability of formula fields?
Choose 3 answers
A. Display the previous value for the field using the PRIORVALUE function.
B. Return and display a field value from another object using a VLOOKUP function.
C. Determine which of three different images to display using IF function.
D. Generate the link using the HYPERLINK function using a specific record in a legacy system.
E. Determine if a datetime field has passed using the NOW function.

Ans C. Determine which of three different images to display using IF function.
    D. Generate the link using the HYPERLINK function using a specific record in a legacy system.
    E. Determine if a datetime field has passed using the NOW function.
Ref:
https://developer.salesforce.com/trailhead/en/point_click_business_logic/formula_fields
VLOOKUP only available in validation rules

Q 9 In a single record, a user selects multiple values from a multi-select picklist.
How are the selected values represented in Apex?
A. As a String with each value separated by a comma.
B. As a List<String> with each value as a element in the list.
C. As a String with each value separated by semi colon.
D. As a Set<String> with each value as a element in the set.

Ans C. As a String with each value separated by semi colon.

Q 10 What is the capability of Force.com IDE? Choose 2 answers
A. Edit metadata components
B. Run Apex tests
C. Run debug logs
D. Roll back deployments

Ans A. Edit metadata components
B. Run Apex tests
Ref:
https://developer.salesforce.com/page/Force.com_IDE

Q11 A Hierarchy Custom Setting stores a specific URL for each profile in Salesforce.
Which statement can a developer use to retrieve the correct URL for the current user's profile and display this Visualforce Page?
A. {$Setup.Url_Settings_c.Instance[Profile.Id].URL__c}
B. {!$Setup.Url_Settings_c.URL__c}
C. {!$Setup.Url_Settings_c[Profile.Id,URL__c}
D. {!$Setup.Url_Settings_c[$Profile.Id,URL__c}

Ans B. {$Setup.Url_Settings_c.URL__c}

Ref: http://blog.jeffdouglas.com/2010/02/08/using-hierarchy-custom-settings-in-salesforce-com/

Q12 How many specific levels can be returned in a single query?
A.3
B.5
C.1
D.7

Ans C. 1

Q 13 A developer needs to know if all tests currently pass in salesforce environment
Which feature can the developer use?
Choose 2 answers
A. Developer Console.
B. ANT Migration Tool
C. Salesforce UI Apex Test Execution
D. Workbench Metadata Retrieval

Ans A. Developer Console.
    C. Salesforce UI Apex Test Execution

Q14 The sales management team requires that the Lead Source field of the Lead record be populated when a Lead is converted. What would a developer use to ensure that a user populates the Lead Source field prior to converting a Lead?

A. Process builder
B. Validation rule
C. Formula field
D. Workflow rule

Ans B. Validation rule

Q15 A developer created an Apex trigger using the Developer Console and now wants to debug code. How can the developer accomplish this in the Developer Console?

A. Open the Logs tab in the Developer Console.
B. Select the Override Log Triggers checkbox for the trigger.
C. Add the user name in the Log Inspector.
D. Open the Progress tab in the Developer Console.

Ans A. Open the Logs tab in the Developer Console.

Q16 What are the supported content sources for custom buttons and links?
(Choose 2 Answers)
A. VisualForce Page.
B. Static Resource.
C. URL.
D. Chatter File.
E. Lightning Page.

Ans A. VisualForce Page.
    C. URL.

Q17 What actions types should be configured to display a custom success message?
A. Update a record.
B. Post a feed item.
C. Delete a record.
D. Close a case.

Ans A. Update a record.

Q18 When creating a record with a Quick Action, what is the easiest way to post a feed item?
A. By selecting create case feed on the quick action.
B. By adding a trigger on the new record.
C. By adding a workflow rule on the new record.
D. By selecting create case feed on the new record.

Ans A. By selecting create case feed on the quick action.

Q19 What is the easiest way to verify a user before showing them sensitive content?
A. Sending the user a SMS message with a passcode.
B. Calling the generateVerificationUrl method in apex.
C. Sending the user an Email message with a passcode.
D. Calling the Session.forcedLoginUrl method in apex.

Ans B. Calling the generateVerificationUrl method in apex.

Q20 What features are available when writing apex test classes? (Choose 2 Answers)
A. The ability to select error types to ignore in the developer console.
B. The ability to write assertions to test after a @future method.
C. The ability to set and modify the CreatedDate field in apex tests.
D. The ability to set breakpoints to freeze the execution at a given point.
E. The ability to select testing data using csv files stored in the system.

Ans C. The ability to set and modify the CreatedDate field in apex tests.
    E. The ability to select testing data using csv files stored in the system.


Q21 public class myController {
public string myString;
public string getMyString(){
return 'getMyString';
}
public string getStringMethod1(){
return myString;
}
public string getStringMethod2(){
if(myString == null)
myString = 'Method2';
return myString;
}
}
<apex:page controller="myController">
{!MyString}, {!StringMethod1}, {!StringMethod2}, {!MyString}
</apex:page>
What does the user see when accessing the custom page?
A. getMyString,
B. , , Method2,
C.Method2, getMyString
D. getMyString„ Method2, getMyString

Ans D. getMyString„ Method2, getMyString

Q22 A developer needs to ensure there is sufficient test coverage for an Apex Method that interacts with Accounts. The developer needs to create test data.
What is the preferred way to load this test data into Salesforce?
A. By using Documents.
B. By using HttpCalloutMocks.
C. By using WebServiceTests.
D. By using Static Resources.

Ans D. By using Static Resources

Q23 What is the benefit of the Lightning Component framework?
A. Better integration with Force.com sites.
B. More pre-built components to replicate the Salesforce look and feel.
C. More centralized control via server-side logic.
D. Better performance for custom Salesforce 1 Mobile apps.

Ans B. More pre-built components to replicate the Salesforce look and feel.


Q24 How would a developer determine if a CustomObject__c record has been manually shared with the current user in Apex?
A. By querying the role hierarchy.
B. By calling the isShared() method for the record.
C. By querying CustomObject__Share.
D. By calling the profile settings of the current user.

Ans C. By querying CustomObject__Share.

Q25 Which trigger event allows a developer to update fields in the Trigger.new list without using an additional DML statement? (Choose 2)
A. After update.
B. Before insert.
C. Before update.
D. After insert.

Ans B. Before insert.
C. Before update.

Q26 What is a valid way of loading external JavaScript files into a Visualforce page? (Choose 2)
A. Using an (apex:includeScript)* tag. \>
B. Using an (apex:define)* tag.
C. Using a (link)* tag.
D. Using a (script)* tag.

Ans A. Using an (apex:includeScript)* tag.
D. Using a (script)* tag.
*For this question, replace ( ) with less/greater than symbols.

Q27 Where would a developer build a managed package?
A. Developer Sandbox
B. Unlimited Edition
C. Partial Copy Sandbox
D. Developer Edition

Ans D. Developer Edition

Q28 What is the correct way to describe how Model-View-Controller (MVC) architecture is implemented on the Salesforce platform?

A. Model: Standard and Custom Objects; View: Visualforce Pages; Controller: s-Controls
B. Model: Schema Builder; View: List Views; Controller: Setup Console
C. Model: Standard and Custom Objects; View: Visualforce Pages; Controller: Apex Code
D. Model: Apex Code; View: List Views; Controller: Setup Console

Ans C. Model: Standard and Custom Objects; View: Visualforce Pages; Controller: Apex Code

Q29 What is valid in the where clause of a SOQL query? Choose 2 answers.
A. A geolocation field.
B. An encrypted field.
C. An aggregate function.
D. An alias notation.

Ans A. A geolocation field.
D. An alias notation.


Q30 A developer creates a method in an Apex class and needs to ensure that errors are handled properly. What would the developer use? Choose 3 answers.
A. ApexPages.addErrorMessage()
B. A custom exception
C. .addError()
D. Database.handleException()
E. A try/catch construct

Ans B. A custom exception
C. .addError()
E. A try/catch construct

Q31 In the Lightning Component framework, where is client-side controller logic contained?
Choose 1 answer.
A. Apex
B. Visualforce
C. HTML
D. JavaScript

Ans D. JavaScript

Q32 Which use case requires a partial copy or full sandbox? Choose 3 answers.
A. Scalability Testing
B. Development Testing
C. Quality Assurance Testing
D. Batch Data Testing
E. Integration Testing

Ans A. Scalability Testing
D. Batch Data Testing
E. Integration Testing


Q33 Universal containers wants to rollout new product bundles with several pricing options. Pricing options include product-price bundles, account specific pricing and more. Which product satisfies the needs?
A. Workflow on Opportunity/Opportunity Product
B. Custom Appexchange-app for product-pricing
C. Formula fields on Opportunity/Opportunity Product
D. Lightning process builder

ANs B. Custom Appexchange-app for product-pricing

Q34 Universal containers has included its orders as an external data object into Salesforce. You want to create a relationship between Accounts and the Orders object (one-to-many relationship) leveraging a key field for account which is on both external object and Account. Which relationship do you create?
A. Master Detail Relationship
B. Indirect Lookup Relationship
C. Lookup Relationship
D. Hierarchical Relationship
E. External Lookup Relationship

Ans B. Indirect Lookup Relationship

Q35 Universal containers has a custom object that has a N:M relationship with  opportunityLineItem carrying price and amount information. In order to compute total amounts and total prices per Opportunity using Rollup summary fields, what field type will you use?
A. Crossobject
B. Lookup
C. Master-Detail
D. Junction

ANs C. Master-Detail

Q36 Universal containers has a custom object that has a N:M relationship with opportunityLineItem carrying price and amount information. In order to compute total amounts and total prices per Opportunity using Rollup summary fields, what relationship type will you use?
A. Crossobject
B. Lookup
C. Master-Detail
D. Junction

Ans D. Junction

Q37 Universal containers want an org for development which can be refreshed in every 5 days with all the configuration and some data. What org do you choose?
A. Developer Sandbox
B. Developer Pro Sandbox
C. Partial copy sandbox
D. Full Sandbox

Ans C. Partial copy sandbox

Q38 Which Apex collection is used to ensure all values are unique?
A. An Sobject
B. Set
C. List
D. Enum

Ans B. Set

Q39 Universal Container installs an unmanaged package. Which of the following are true? Choose 2.
A. Tests are executed during deployment
B. Unmanaged packages can be upgraded
C. Unmanaged packages don't have a version number
D. Unmanaged packages have a namespace prefix
E. Components of unmanaged packages can be edited

Ans C. Unmanaged packages don't have a version number
E. Components of unmanaged packages can be edited

Q40 Universal Container want to store an area code and wants to be able to search for it in searches. Which are possible fields to store the data? (choose 2)
A. Phone
B. Email
C. Text
D. Multi Picklist

Ans A. Phone
C. Text