Process Automation & Logic: Basic Apex 1 Flashcards

Variable | Constants | Methods | Modifiers | Interfaces (79 cards)

1
Q

What are the supported Primitive Data Types?

A

Blob
Boolean
Date
DateTime
Decimal
Double
ID
Integer
Long
Object
String
Time

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

What are the supported Non-Primitive Data Types?

A

List
Set
Map
Enum
sObject
Class Object

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

What is the Object Data Type?

A

An Object can be used for any data type supported in Apex as all Apex data types inherit from Object.

An Object variable that represents a more specific data type can be cast to the underlying data type.

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

How can we declare a Date variable?

A

Date customDate = Date.newInstance(1939, 9, 1);

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

What is the Blob data type?

A

A Blob variable is used to store a collection of binary data as a single object. The value of method of the Blob class can be used to declare a Blob variable by casting a specified string.

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

What is a collection variable?

A

Collection variables are a type of variable that can be used to store multiple variables of the same data type.

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

What is a List Data Type?

A

A list is an ordered, indexed (zero-based) collection of primitives or non-primitives.

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

What is a SET Data Type?

A

A set is an unordered collection of unique elements and cannot contain duplicate values.

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

What is a MAP Data Type?

A

A Map is a collection of key value pairs where the Keys are a set. We can declare a Map like this: Map<Integer, String> productMap = new Map<Integer, String>{8976 => ‘Laptop E15000’, 8977 => ‘Keyboard R500’, 8978 => ‘Mouse L100’};

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

Can a MAP be populated directly from a SOQL query?

A

Yes, like this: Map<Id, Opportunity> oppMap = new Map<Id, Opportunity>([SELECT Id, Name, StageName FROM Opportunity]);

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

What is an ENUM?

A

Enum is a data type that specifies a set of constants. Example: public enum Day { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, SATURDAY }

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

How can we declare an sObject variable?

A

Example: sObject obj = new Account();

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

An object of a class can be declared using the ______ and the new operator.

A

class name

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

How do we create a variable of a class object?

A

Example: SalesOrder order = new SalesOrder(‘Laptop T1000’, 1, 126782);

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

Apex is a strongly-typed language where the data type must be declared before a variable can be used. True of False?

A

True

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

What is two ways we can declare Constant variables?

A

Use the Final keyword for a variable whose value should not be altered OR use the Enum Data type

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

Apex enforces strict data typing where a variable is required to only accept values of the data type that is explicitly declared. True or False?

A

True

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

What values are variables assigned if no value is assigned during initialization?

A

Null

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

Two variables with the same name cannot exist in the same _______, or in the same “hierarchy” of blocks they are contained in.

A

scope

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

The block where a variable is declared determines the scope of that variable. A variable will be available to its _______, but a variable declared in a sub-block will not be available to its parent block.

A

sub-blocks

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

What is a Constant?

A

Constant is a variable whose value cannot change after it has been assigned a value.

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

_______ can be defined using the final keyword on initialization, which means that the variable can be assigned at most once.

A

Constants

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

An ____________ is a statement that places a value into a variable.

A

assignment statement

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

What is an Expression?

A

An expression is a construct made up of variables, operators and/or method invocations, that evaluates to a single value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
_______ can be used to join expressions with one another to create compound expressions.
Operators
26
What is an assignment statement?
An assignment statement can assign a left value to a new value expression or an inline SOQL query such as: Account[] accounts =[SELECT Id, Name FROM Account WHERE BillingCity ='Rome'];
27
Static variables declared in an Apex class can be directly accessed without instantiating using the following syntax:
ClassName.StaticVariableName
28
What is the Transient keyword used for?
The transient keyword is used to declare variables that cannot be saved. One common usage is a field on a Visualforce page that is utilized only during the page request.
29
Depending on the data types used in an assignment statement, there are cases where explicit conversion is not required. True or False?
True
30
In general, Apex requires ___________ of one data type to another. For example, using String.format, String.valueOf, or casting a variable to String before assigning it to a String data type variable.
explicit conversion
31
What is Implicit Conversion?
Lower numeric types can be assigned to higher numeric types without explicit conversion. So, directly assigning an Integer to a Decimal is allowed, but the doing the opposite will throw an error.
32
In addition to numeric types, other data types can be implicitly converted such as?
❖A variable of ID data type can be assigned to a String. ❖Strings can be assigned to an ID, but because ID validation will execute at runtime, an exception may be thrown if the value is not a valid ID. ❖As such, the instanceOf keyword can be used to test if a string is valid ID.
33
What is an Apex Method?
An Apex method consists of statements grouped together as a single unit in an Apex class that perform a specific business logic.
34
Access modifiers such as public or protected can be added to the method definition, but it is optional. True or False?
True
35
If a method does not return a value, the void keyword should be used instead of a return type. True or False?
True
36
Input parameters must be separated by commas. Each parameter should be preceded by its datatype and enclosed in parentheses(). True or False?
True
37
If there are no parameters, a set of empty parentheses() should be used. True or False?
True
38
The static keyword can be used to define a static method, which does not require an instance of a class in order to run. True or False?
True
39
What is the Override Keyword used for?
The override keyword can be used to override a method in a class that is defined as virtual or abstract.
40
What is required when declaring a method in an Apex Class?
A Name The Data Type of the value returned Method Parameters A Body enclosed with braces
41
Method Syntax Example:
[public | private | protected | global] [override] [static] data_type method_name (input parameters) { // body of the method}
42
One must use an access modifier in the declaration of a ________ Apex class.
top-level
43
The default access modifier is ______, which means that the method or variable can only be accessed within the Apex class in which it is defined.
private
44
The _______ access modifier means that the method or variable can be used by any Apex in the application or namespace.
public
45
The ________ access modifier means that the method or variable can be used by any Apex code that has access to the class and not just the Apex code in the same application.
global
46
The ________ access modifier means that 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.
protected
47
What is an Interface used for?
An interface is used to require a class to implement specific methods.
48
The structure of an interface is similar to a class, but it uses the ________ keyword and only contains method signatures.
interface
49
What does an Interfaces method signature contain?
A method signature does not contain a body or access modifier and only consists of the name and any method parameter or return type.
50
An Apex class uses an interface by using the _________ keyword and is required to provide the body for all methods contained in the interface
implements
51
A class can implement multiple interfaces by separating the names of the interfaces with a comma after the implements keyword. True or False?
True
52
An interface separates the ____________ of a method from the declaration of that method.
implementation logic
53
Batch Apex ___________ which enables it to execute complex, long-running operations over small batches of thousands of records.
implements an interface
54
An Apex class that implements the ________________ interface is required to use batch Apex.
Database.Batchable
55
The _________________ method can be used to execute a batch Apex job. It requires two parameters: an instance of the batch Apex class and an optional scope (number of records to pass into the method).
Database.executeBatch
56
Batch Apex can be scheduled by implementing an interface that enables it to be scheduled as an Apex job. True or False?
True
57
To schedule an Apex class, it must implement the __________ interface.
Schedulable
58
The Schedule Apex page in Setup or the __________ method can be used to specify the schedule.
System.schedule
59
A schedulable Apex class must implement the __________ method, which contains the logic that needs to be executed on a scheduled manner.
execute
60
What is Queueable Apex?
Queueable Apex allows you to add asynchronous jobs to the queue and monitor them. It offers enhancements over using @future methods.
61
In Queueable Apex, The ______________ method submits a job and returns a Job Id that can be used to monitor the job status.
System.enqueueJob()
62
A Queueable class can contain non-primitive member variables such as sObjects or custom Apex classes. True or False?
True
63
Jobs can be chained or executed sequentially by having one Queueable job enqueue the next job in its execute() method. True or False?
True
64
Queueable jobs can be delayed by setting the delay duration in Apex Settings in Setup or via Apex code. True or False?
True
65
A queueable class must implement the __________ and contain its processing logic in a method called execute.
Queueable interface
66
The ______________ of Queueable jobs can be configured when calling System.enqueueJob(). It can be used to prevent runaway recursive jobs from consuming the daily async Apex limit.
maximum stack depth
67
To ensure that only unique queueable jobs are enqueued, the __________ property can be set.
Duplicate Signature
68
What is a Transaction Finalizer?
Transaction Finalizers implement an interface which enable them to attach actions to a queueable Apex job.
69
The _____________ interface is used to attach an action to the asynchronous Apex job when it succeeds or fails.
System.Finalizer
70
The System.Finalizer can only be used on asynchronous Apex jobs that use the Queueable framework. True or False?
True
71
What is a use case of System.Finalizer Interface?
An ideal use case is to re-enqueue an Apex job (up to 5 times) when its operation fails.
72
Finalizers can be implemented as inner classes. Alternatively, Queueable and Finalizer interfaces can be implemented in the same Apex class. True or False?
True
73
The System.FinalizerContext interface contains four methods. True or False?
True
74
What does the getAsyncApexJobId method do?
Returns the ID of the Queueable job that is attached to the finalizer
75
What does the getRequestId method do?
Returns the request ID shared by both the finalizer execution and the Queueable job
76
What does the getResult method do?
Returns the System.ParentJobResultenum which represents the result of the queueable job. Its value can either be SUCCESS or UNHANDLED_EXCEPTION
77
What does the getException method do?
Returns the exception if the result of the queueable job is UNHANDLED_EXCEPTION
78
What does the Comparable Interface allow?
Custom sort logic
79
The _________________ can be used to create custom sort logic for List collections by passing an instance of the implementing class to the sort method of the List class.
Comparator interface