Process Automation & Logic: Basic Apex 1 Flashcards
Variable | Constants | Methods | Modifiers | Interfaces (79 cards)
What are the supported Primitive Data Types?
Blob
Boolean
Date
DateTime
Decimal
Double
ID
Integer
Long
Object
String
Time
What are the supported Non-Primitive Data Types?
List
Set
Map
Enum
sObject
Class Object
What is the Object Data Type?
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 can we declare a Date variable?
Date customDate = Date.newInstance(1939, 9, 1);
What is the Blob data type?
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.
What is a collection variable?
Collection variables are a type of variable that can be used to store multiple variables of the same data type.
What is a List Data Type?
A list is an ordered, indexed (zero-based) collection of primitives or non-primitives.
What is a SET Data Type?
A set is an unordered collection of unique elements and cannot contain duplicate values.
What is a MAP Data Type?
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’};
Can a MAP be populated directly from a SOQL query?
Yes, like this: Map<Id, Opportunity> oppMap = new Map<Id, Opportunity>([SELECT Id, Name, StageName FROM Opportunity]);
What is an ENUM?
Enum is a data type that specifies a set of constants. Example: public enum Day { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, SATURDAY }
How can we declare an sObject variable?
Example: sObject obj = new Account();
An object of a class can be declared using the ______ and the new operator.
class name
How do we create a variable of a class object?
Example: SalesOrder order = new SalesOrder(‘Laptop T1000’, 1, 126782);
Apex is a strongly-typed language where the data type must be declared before a variable can be used. True of False?
True
What is two ways we can declare Constant variables?
Use the Final keyword for a variable whose value should not be altered OR use the Enum Data type
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?
True
What values are variables assigned if no value is assigned during initialization?
Null
Two variables with the same name cannot exist in the same _______, or in the same “hierarchy” of blocks they are contained in.
scope
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.
sub-blocks
What is a Constant?
Constant is a variable whose value cannot change after it has been assigned a value.
_______ can be defined using the final keyword on initialization, which means that the variable can be assigned at most once.
Constants
An ____________ is a statement that places a value into a variable.
assignment statement
What is an Expression?
An expression is a construct made up of variables, operators and/or method invocations, that evaluates to a single value.