General Platform Developer 1

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

A roll-up summary field can calculate the value of formula fields unless:

- The formula field contains cross-object field references - The formula field contains functions that derive values dynamically, such as NOW or TODAY

A developer is required to access Opportunity records on a Visualforce page without using a custom controller. How can the developer satisfy this requirement?

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

How would a developer write a query to return the number of leads for each lead source?

A GROUP BY clause can be used with COUNT(fieldName) to allow analyzing records and returning summary reporting information. SELECT LeadSource, COUNT(Name) FROM Lead GROUP BY LeadSource

Primitive Data Type - Blob

A blob vqariable is used to store a collection of binary data as a single object, the valueof method of the blob class can be used to declare a blob variable by casting a specified string

Class

A class acts as a blueprint to create objects from

Constructor

A constructor is code that is invoked when an object is created from the class blueprint. It has the same name as the class name. It should not return a value. What is the method in the second line of the code snippet below called? public class sampleClass() { public sampleClass() { //logic here } public void sampleMethod() { //logic here } }

Primitive Data Type - Double

A double can be declared as a numerical value with a decimal point that has a min value and max value

Collection - List

A list can be declared using a List keyword followed by the primitive data, sObject, nested list, map or set type within characters. List methods such as add(), get(), and set() can be used to access elements in a list. List<Account> accouints = [Select Name FROM Account LIMIT 10];

Collection - Set

A set can be declared using the Set keyword followed by the primitive data type name within characters. Set methods as add() and remove() can be used to access elements in a set Example: Set<Id> accIds = new Set<Id>() ; for (Contact con : [SELECT AccountID FROM Contact LIMITS 5]) { accIds.add(con.AccountID); } System.debug ('Set of Account IDs: ' + accIds) ;

Given the following options, what are the valid ways to declare a collection variable?

A. new List<Account>() B. new Contact[]{<elements>} C. new Map<Id, Account>()

Which of the following statements about the IF-ELSE statement are true?

An IF statement can be followed by a discretionary ELSE statement, which executes when the Boolean expression is false. The IF-ELSE statement permits a choice to be made between two possible execution paths.

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?

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

Apex is typically executed in system mode, but which of the following executes code as the current user?

Anonymous Code Blocks

Roll Up Summary Functions

Calculate Sum, Min, Max or Record Count of Field

How can a developer check if a user has read access to a field and the field can be displayed on a Visualforce page?

Call the isAccessible() method of Schema.DescribeFieldResult to verify field level read permission

What is the method in the second line of the code snippet below called? public class sampleClass() { public sampleClass() { //logic here } public void sampleMethod() { //logic here } }

Constructor

Which of the following DML operations will allow other records in a list to be inserted even if there are records that failed?

Database.insert(sObjectsToCreate,false);

Which data type is appropriate for a numerical value of 726.234 stored in the variable totalCost?

Decimal totalCost; It is best to use Decimal because it is a number (32-bit) that includes a decimal point unlike Integer and long. Also, double (64-bit) can be used for larger values with decimal points.

Apex Constants

Declare a variable whose value should not change Final Variables- Final keyword for a variables whose value should not be altered Enum - use enum keyword to specific a set of constants

Complex Data Types

Defined by the user based on programming requirements

Other useful methods of DescribeSObjectResult include isAccessible(), isCreateable, and isSearchable().

DescribeSObjectResult

describeSObjects(sObjectTypes)

Describes metadata (field list and object properties) for the specified sObject or array of sObjects.

dot notation

Dot notation is how you access the fields and/or methods of an object. You use the name (the reference to the object in the memory) followed by a . (dot), then the name of the variable or method you want to call, like blueCar.model, which will give you the value of the model variable of the blueCar instance from the memory.

A developer needs to initialize a numerical value of 17. What data type should the developer use?

Integer num = 17; Integer is a 32-bit number that does not include a decimal point. M

List vs Set

List is not unique, Sets are

Roll Up Summaries - Limitations

Max 25 per object Not available on Lookup relationships (only rolls up to master object on a MD relationship, unless it's opty product or account-opportunity) not available on certain types of formula fields that contain cross object references

instance of a class

Object Each object, when it's instantiated (created) from the class, gets its own little space in the memory, which we can access by the name we give it at the time of creation.

Roll Up Summary Limitation Options (Solutions)

PB and VF Trigger on various DML events on child object batch / scheduled apex 3rd party tools from app exchange

A PageReference is a reference to an instantiation of a page. Which of the following are valid means of instantiating a PageReference?

Page.existingPageName PageReference pageRef = new PageReference('URL'); ApexPages method: PageReference pageRef = ApexPages.currentPage();

Apex Variables - Data Types

Primitiive Data Types - Boolean, string, integer, decimal, double, long, date, datetime, blob and time Collections - lists, set, and map sObjects - Generic and Specific sObjects Apex Class Objects - Objects of user-defined and System-supplied apex classes

What is the discretionary clause that can be added to a SOSL query to specify the information to be returned in the text search result?

RETURNING is an optional clause that can be added to a SOSL query to specify the information returned in the text search result. Use the RETURNING clause to restrict the results that are returned from the search()

What will be the result if the code below is executed when the variable testRawScore is 75? if (testRawScore >= 90) { gradeEqual = 'A'; } else if (testRawScore >= 80) { gradeEqual = 'B'; } else if (testRawScore >= 70) { gradeEqual = 'C'; } else if (testRawScore >= 60) { gradeEqual = 'D'; } System.debug(gradeEqual);

Repeated ELSE-IF statements will navigate down through each IF and ELSE IF statement UNTIL ONE of the expressions evaluates to true. Even though the last else-if statement contains a condition that is true, it is not executed. The code stops after evaluating the prior statement and assigning the value 'C' to the variable 'gradeEqual'.

A developer notices that the code below returns only 20 Account records though she expected 60. Which of the following is true regarding SOSL query limits? FIND {test} RETURNING Account(id), Contact, Opportunity LIMIT 60

Results were evenly distributed among the objects returned.

describeDataCategoryGroups(sObjectNames)

Returns a list of the category groups associated with the specified objects.

getGlobalDescribe()

Returns a map of all sObject names (keys) to sObject tokens (values) for the standard and custom objects defined in your organization.

GroupStructures(pairs)

Returns available category groups along with their data category structure for objects specified in the request.

describeTabs()

Returns information about the standard and custom apps available to the running user.

A developer needs to get the Contact records with a last name that starts with 'Ab'. What code in the options below will satisfy his requirements?

SELECT Id, LastName FROM Contact WHERE LastName LIKE 'Ab%' The % and _ wildcards are supported for the LIKE operator. The % wildcard matches zero or more characters. The _ wildcard matches exactly one character.

how to SOQL query a geolocation or address fields Lat Long values? Which Statement is best?

SELECT Id, Name, Location_latitude__c, Location__Longitude__s FROM CustomObject__c records with locations saved in geolocation or address fields the lat/long can be retrienved by appending __s to field name rather than __c

SObject variables

SObject variables can be used for storing records of standard or custom objects.

SOQL

Salesforce Object Query Language

SOSL

Salesforce Object Search Language search for or select records

What will be the output if the code below is executed when the value of testRawScore variable is 75? if (testRawScore >= 90) { gradeEqual = 'A'; } if (testRawScore >= 80) { gradeEqual = 'B'; } if (testRawScore >= 70) { gradeEqual = 'C'; } if (testRawScore >= 60) { gradeEqual = 'D'; } System.debug('Value of gradeEqual = ' + gradeEqual);

Since there is no ELSE statement in the code, the IF statements will continue to be evaluated, even if one of the conditions is met. Since the value of testRawScore (75) is greater than 70, the code within the third IF statement assigns the value 'C' to the 'gradeEqual' variable. But since 75 is also greater than 60, the last IF statement assigns the value 'D' to the 'gradeEqual' variable, replacing the prior value. As a result, the final value of the variable is 'D'.

The developer executes the code below and an error is returned indicating that a variable is not properly declared. String str = new String(); public void stringDisplay() { str = 'Hello'; system.debug(str); } What is the proper way of declaring a String data type variable?

String str; String is a primitive data type, so it does not need to be instantiated with a new() command. It can be declared with or without an initial value.

What is the proper way of declaring a String data type variable?

String variableName; String variableName = 'value'

How can a developer check if the current user is able to delete the current object?

T he isDeletable() method of the DescribeSObjectResult Class

How can a developer access a static variable named TaxRate declared in a different Apex class named TaxCalculation?

TaxCalculation.TaxRate Static variables declared in an Apex class can be directly accessed without instantiating using the following syntax: ClassName.StaticVariableName. A static method or variable does not require an instance of the class in order to run. Static variables are not methods, so no parentheses are needed.

What is difference between Database.insert(sObjectsToCreate,false); Database.insert(sObjectsToCreate,true);

The Database insert method has an unnamed Boolean parameter (think of it as the 'all or nothing' parameter) that when set to false, if a record in the insert list fails, the remaining records in the list can still succeed. If 'all or nothing' is set to true, a single record failure rolls back the entire DML operation.

How can a dynamic SOQL query be created at runtime using input from an end user?

The Database.query(string) method can be used to return a single or list of sObjects.

Describe IF-ELSE statement

The IF-ELSE statement permits a choice to be made between two possible execution paths, not more. The ELSE statement executes (secondary path) when the IF clause is false.

An organization has enabled Multiple Currencies. A developer needs to calculate the total of the Estimated_value__c on CampaignMember object using a roll-up summary field on Campaign object named Total_estimated_value__c. What will be the currency of the Total_estimated_value__c field?

The field values in Estimated_value__c from CampaignMember object are converted into the currency of the Campaign, and the Total_estimated_value__c is shown using the currency of the Campaign. If your organization uses multiple currencies, the currency of the master record determines the currency of the roll-up summary field. For example, if the master and detail records are in different currencies, the detail record value is converted into the currency of the master record.

What does getDescribe() method do

The getDescribe() method is used to obtain information on the field

How to check the current user's read access for a field

The isAccessible method of Schema.DescribeFieldResult can be called to

What is the output of the code below? Integer z = 5; do { z = z + 1; } while(z <= 15); System.debug(z); Choose 1 answer.

The loop will iterate until such time the condition of the while block is evaluated as false. Prior to this, the variable z is equal to 16.

Static methods, variables, and initialization code have these characteristics.

They're associated with a class. They're allowed only in outer classes. They're initialized only when a class is loaded. They aren't transmitted as part of the view state for a Visualforce page.

Instance methods, member variables, and initialization code have these characteristics.

They're associated with a particular object. They have no definition modifier. They're created with every object instantiated from the class in which they're declared.

Model

This is actually where your data is stored and can be used. To store data, you need objects or fields, and these are considered to be part of the model.

View

This is whatever end users see and interact with; that is, what displays data to the clients or customers. This allows you to control how (and what) data is shown on the user interface. So, standard pages, page layouts, Visualforce pages, Lightning components, console layouts, and mini page layouts are all considered part of the view.

Controller

This refers to the actual logic and actions that are executed when someone interacts with Visualforce pages, standard pages, or Lightning components. The controller is the link that binds the client side and the server side. It will mostly consist of Apex; this means that even when building Lightning components, you'll probably need Apex to get the data from the database on the server and pass it to the JavaScript controller. The new Lightning Data Service from Salesforce acts like a standard controller—it connects to objects and fields in the database without writing any Apex.

Apex Expressions

Use expressions and operators to put values into variables Assignment Statement - assign a value to a variable Expressions - use a construct made up of variables, operators and method invocations Operators - use expression operators to join an expression with another and form compound expressions

Class Object

Used to access class methods and variables

Enum

Used to define a set of possible values

sObject

Used to store a record of an object

Set

Used to store a unique collection of elements

List

Used to store an ordered collection of elements

Map

Used to store key-value pairs of elements

do { statement } while (Boolean_condition);

What is the correct syntax for a Do While procedural loop?

When to Use a Blob

When an attachment in SF needs stored as a variable It can be used to convert the attachment into a single object

When to use a Collection Map

When data needs to be stored and accessed using identifiers or keys. For example, IDs and names of account records can be stored as key-value pairs for easier manipulation in apex.

When to use a Collection List

When several elements of a particular data type need to be stored in a specific order

When to use a Collection Set

When unique elements of a particular data type need to be stored in no specific order

When to use Apex

You can use Apex if you want to do the following things: Create web services Create email services Create complex validations over multiple objects Create complex business processes that are not supported by workflow, Process Builders, or Visual Flow Create custom transactional logic (more than one record or object, for example, overnight batches) Custom logic for Visualforce pages Server-side controllers for Lightning components

Which correctly describes the code snippet below? public with sharing class containerClass { //Insert code here public class innerClass { //Insert code here } } Choose 2 answers.

[without sharing] will be the default for the inner class The innerClass does not inherit the sharing setting of the containerClass. "without sharing" is the default sharing setting for Apex classes. Inner classes do not inherit the sharing setting from their container class.

There are several escape sequences that can be used in queries so that a user query can contain special characters. Which of the following are valid escape sequences?

\" \n \'

you require a varaible numberOfStudents with a constant value of 25 that is only accessible within the Apex class in which it is defined what is the best variable declaration

a Private static final integer numberOfStudents = 25; a variable numberOfStudents with a constant (STATIC, FINAL) value of 25

Primitive Data Type - Long

a long variable can be declared as a numerical value without a decimal point that has a min and max value

Collection - Map

a map can be declared using the Map keyword followed by the data types of the key and value within the characters. Key-value pairs can be populated by specifying the key and then the value for that key using => within curly brace ({}) syntax Example: Map productMap = new Map {892 => 'Laptop E12', 4965 => 'Keyboard => l100'}; Map can be populated from the results returned by the SOQL query Map key should be declared with an ID or String data type, and the map value should be declared as an sObject data type. Example: Mapp oppMap = new Map ([SELECT Id, Name, StageName FROM Opportunity]);

RETURNING is an optional clause that can

added to a SOSL query to specify the information returned in the text search result. Use the RETURNING clause to restrict the results that are returned from the search() call.

The isAccessible method of Schema.DescribeFieldResult can be called to

check the current user's read access for a field.

Count variable (class Variable)

count variable, which we declared as static, which means that this is a class variable and not a member variable. This means that contrary to member variables (where each instance will have its own values), the class variable (static) will not get its own instance and will be the same for all objects (instances) created out of the class! In this example, you'll see that in the constructor, we declare count++, which will increment this count variable each time a new instance is created in memory.

Methods

define actions that an Object can perform and what an Object can do, and we call these methods

What is the correct syntax for a Do While procedural loop?

do {statement} while (Boolean_condition);

How can a developer ensure that a variable 'Day' will only contain specific set of constants such as SUNDAY, MONDAY, TUESDAY.....SATURDAY? What should variable 'Day' be declared as?

enum Day{ SUNDAY, MONDAY, ...SATURDAY} An enum is an abstract data type with values that each take on exactly one of a finite set of identifiers that you specify. Use enumerations (enums) to specify a set of constants.

What method can be used to obtain metadata information about all the sObjects in an organization and their fields?

getGlobalDescribe() The getGlobalDescribe() method can be used to return a map of all sObject names (keys) to sObject tokens (values) for the standard and custom objects defined in an organization. The describeSObjects() method can be used to obtain metadata (field list and object properties) for the specified sObject or array of sObjects. The sObjects need to be specified when using this method. There are no methods named describeObjects() and getGlobalSObjects().

How can a developer get all picklist values of a specific field via Apex?

getPicklistValues method is used to retrieve the picklist values.

In the following line of code, why can the helloWorld() method be called directly instead of instantiating the myClass? myClass.helloWorld('Hello');

helloWorld is defined as a static method

In the following line of code, why can the helloWorld() method be called directly instead of instantiating the myClass? myClass.helloWorld('Hello'); Choose 1 answer.

helloWorld is defined as a static method

getGlobalDescribe()

method can be used to obtain metadata information about all the sObjects in an organization and their fields?

sObjects

objects in SF UI

getDescribe() method is used to

obtain information on the field

The describeSObjects() method can be used to

obtain metadata (field list and object properties) for the specified sObject or array of sObjects.

Which of the following access modifiers are supported in Apex?

private global public Supported Apex access modifiers are: Private - this is the default, and means that the method or variable is accessible only within the Apex class in which it is defined. Protected - the method or variable is visible to any inner classes in the defining Apex class, and to the classes that extend the defining Apex class. Public - the method or variable can be used by any Apex in this application or namespace. Global - the method or variable can be used by any Apex code that has access to the class, not just the Apex code in the same application.

A developer requires a variable numberOfStudents with a constant value of 25 that is accessible only within the Apex class in which it is defined. Which of the following is the best variable declaration?

private static final Integer numberOfStudents = 25;

object-oriented programming (OOP)

programming paradigm based on the concept of "objects", which can contain data, in the form of fields (often known as attributes), and code, in the form of methods. A feature of objects is an object's method that can access and often modify the data fields of the object with which they are associated (objects have a notion of "this" or "self"). In OOP, computer programs are designed by making them out of objects that interact with one another. OOP languages are diverse, but the most popular ones are class-based, meaning that objects are instances of classes, which also determine their types.

getPicklistValues method is used to

retrieve the picklist values.

The getGlobalDescribe() method can be used to

return a map of all sObject names (keys) to sObject tokens (values) for the standard and custom objects defined in an organization.

anonymous code blocks

run as the current user permissions

When should a static method or variable be used

to sotre information that is shared across instances of a class to use as a utility method a dev needs to access a method without instantiating a class

Member Variables

we define what each Object has in the class—these are called member variables


Ensembles d'études connexes

Freshman Vocab Final (Good Luck)

View Set

The Value of Healthy Diet and Exercise

View Set

Abnormal Psychology Test 2- Chapter 8

View Set

A level English Language- Gender terminology

View Set

Chapter 9: The Nurse-Client Relationship

View Set

2.0 now the newest Psychology notes for Jacary

View Set

chapter 6: dissonance and justification

View Set

Psalm 118 - Flashcard MC questions - Ted Hildebrandt

View Set