Apex Flashcards

1
Q

what is the transient keyword used for?

A

Use the transient keyword to declare instance variables that can’t be saved, and shouldn’t be transmitted as part of the view state for a Visualforce page.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

True or False?

Declaring variables as transient reduces view state size?

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which of the following are true regarding custom setting data?

Choose 2

A. Custom setting data can be accessed by formula fields, validation rules, Apex and Visualforce pages
B. There are two types of custom setting data, hierarchy and list
C. Custom setting data needs to be queried once using SOQL and then it is stored in the chache
D. Custom setting data cannot be queried using SOQL

A

A. Custom setting data can be accessed by formula fields, validation rules, Apex and Visualforce pages

B. There are two types of custom setting data, hierarchy and list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Can before insert change fields using trigger.new?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Can after insert change fields using trigger.new?

A

Not allowed.
A runtime error is thrown.
Trigger.new is already saved

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Can before update change fields using trigger.new?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Can after update change fields using trigger.new?

A

Not allowed.
A runtime error is thrown.
Trigger.new is already saved

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Can before delete change fields in trigger.new?

A

Not allowed. A runtime error is thrown. trigger.new is not available in before delete triggers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Can after delete change fields in trigger.new?

A

Not allowed. A runtime error is thrown. trigger.new is not available in after delete triggers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Can after undelete change fields in trigger.new?

A

Not allowed. A runtime error is thrown.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Can before insert update original object using an update DML operation?

A

Not applicable. The original object has not been created; nothing can reference it, so nothing can update it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Can after insert update original object using an update DML operation?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Can before update update original object using an update DML operation?

A

Not allowed. A runtime error is thrown.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Can after update update original object using an update DML operation?

A

Allowed. Even though bad code could cause an infinite recursion doing this incorrectly, the error would be found by the governor limits.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Can before delete update original object using an update DML operation?

A

Allowed. The updates are saved before the object is deleted, so if the object is undeleted, the updates become visible.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Can after delete update original object using an update DML operation?

A

Not applicable. The object has already been deleted.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Can after undelete update original object using an update DML operation?

A

Allowed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Can before insert delete original object using a delete DML operation

A

Not applicable. The original object has not been created; nothing can reference it, so nothing can update it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Can after insert delete original object using a delete DML operation

A

Allowed, but unnecessary. The object is deleted immediately after being inserted.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Can before update delete original object using a delete DML operation

A

Not allowed. A runtime error is thrown.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Can after update delete original object using a delete DML operation

A

Allowed. The updates are saved before the object is deleted, so if the object is undeleted, the updates become visible.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Can before delete delete original object using a delete DML operation

A

Not allowed. A runtime error is thrown. The deletion is already in progress.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Can after delete delete original object using a delete DML operation

A

Not applicable. The object has already been deleted.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Can after undelete insert delete original object using a delete DML operation

A

Allowed, but unnecessary. The object is deleted immediately after being inserted.

25
Q

What does Limits.getDMLRows() do?

A

counts the number of records that have been processed with any statement that counts against DML limits

26
Q

What does Limits.getLimitDMLRows() do?

A

returns the actual limit of statements that count against DML limits

27
Q

What is a constructor?

A

code that is invoked when an object is created from the class blueprint

28
Q

Does a constructor need to be written for every class?

A

No

29
Q

What happens if a class does not have a constructor?

A

If a class does not have a user-defined constructor, a default, no-argument, public constructor is used.

30
Q

What does Trigger.old return?

A

A list of the old versions of the sObject record. Only available in update and delete.

31
Q

How do triggers prevent DML operations from occurring?

A

By calling the addError() method on a record or field. A custom error is displayed in the application interface and logged

32
Q

What is true regarding cascading execution of triggers?

A. Cascading execution of triggers will cause an exception
B. Cascading triggers are part of the same execution context with respect to governor limits
C. Each trigger will start a new execution context
D. There is a limit of 5 triggers that can be executed from a cascading execution

A

B. Cascading triggers are part of the same execution context with respect to governor limits

33
Q

How can the relationship between different accounts be recorded and viewed?

Choose 2

A. Using the View Hierarchy link
B. Using the Parent Account field
C. Using the Generate Relationship function
D. Using the Related Account field

A

A. Using the View Hierarchy link

B. Using the Parent Account field

34
Q

Which of the following statements are true when defining Apex classes?

Choose 2

A.  It is optional to specify an access modifier in declaring inner class
B. A top level class can have multiple levels of inner classes
C. It is required to specify an access modifier in declaring top level classes
D. It is optional to specify an access modifier in declaring a top-level class
A

A. It is optional to specify an access modifier in declaring inner class

C. It is required to specify an access modifier in declaring top level classes

35
Q

What does the private access modifier do?

A

declares that this class is only known locally, that is, only by this section of code.

36
Q

What is the default access for inner-classes if you don’t specify a modifier?

A

Private

37
Q

What does the public access modifier do?

A

declares that this class is visible in your application or namespace

38
Q

What does the global access modifier do?

A

declares that this class is known by all Apex code everywhere. All classes that contain methods defined with the webservice keyword must be declared as global. If a method or inner class is declared as global, the outer, top-level class must also be defined as global.

39
Q

What does the virtual definition modifier do?

A

declares that this class allows extension and overrides. You cannot override a method with the override keyword unless the class has been defined as virtual.

40
Q

What does the abstract definition modifier do?

A

The abstract definition modifier declares that this class contains abstract methods, that is, methods that only have their signature declared and no body defined.

41
Q

What does the protected access modifier do?

A

enables a method to be visible to inner classes of the Apex class it is defined in as well as extensions of the class

42
Q

Can you use the protected access modifier on static methods?

A

No.

It is only allowed on instance methods and member variables.

43
Q

What is an Apex transaction?

A

Single unit of work when you make a request to Salesforce.

44
Q

What are governor limits based on?

A

One Apex transaction

45
Q

What is true regarding a future method?

Choose 2:

A. Methods that are annotated with @future identify methods that are executed asynchronously.
B. Methods annotated with @future can only return a void type.
C. A method annotated with @future can only return a void type
D. Methods that are annotated with @future identify methods that are executed synchronously

A

A. Methods that are annotated with @future identify methods that are executed asynchronously.

B. Methods annotated with @future can only return a void type.

46
Q

When should you use the @future annotation?

A

to identify methods that are executed asynchronously.

47
Q

When does a method with @future annotation execute?

A

When Salesforce has available resources

48
Q

What is the only return type @future methods can have?

A

void

49
Q

What is needed to allow @future methods to callout to external web services?

A

(callout=true)

50
Q

What does trigger.new contain?

A

A list of new versions of records and is available in insert, update, and undelete triggers

51
Q

As per the order of execution, when will an email created from a workflow email alert be sent?

A. After all DML operations are committed to the database
B. Before entitlement rules execution
C. When all before triggers are executed
D. After workflow rule execution

A

A. After all DML operations are committed to the database

52
Q

Which features are available in Visual Studio Code?

Choose 2

A. Process Builder
B. Schema Builder
C. Code Editor
D. Execute Anonymous code

A

C. Code Editor

D. Execute Anonymous code

53
Q

Because Apex runs in a multitenant environment, the Apex runtime engine enforces limits to ensure that Apex code or processes don’t monopolize shared resources. What are valid examples of these limits?

Choose 3

A. Time executing a SOQL query
B. Total number of records retrieved by SOQL queries
C. CPU time per transaction
D. Maximum execution time for DML operation
E. Maximum number of records that can be stored?

A

A. Time executing a SOQL query

B. Total number of records retrieved by SOQL queries

C. CPU time per transaction

54
Q

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

Choose 2

A. PageReference.page(‘URL’)
B. Page.existingPageName
C. ApexPages.Page().existingPageName
D. PageReference pageRef = new PageReference(‘URL’);

A

B. Page.existingPageName

D. PageReference pageRef = new PageReference(‘URL’);

55
Q

When should you use Page.existingPageName?

A

To refer to a PageReference for a Visualforce page that has already been saved in your organization

56
Q

When should you use PageReference pageRef = new PageReference(‘URL’);

A

When creating a PageReference to any page that is hosted on the Force.com platform

57
Q

When should you use PageReference pageRef = ApexPages.currentPage();

A

When instantiating a PageReference object for the current page

58
Q

When should you use a PageReference Class?

A

To view or set query string parameters and values for a page

To navigate the user to a different page as the result of an action method