Apex Code 33% Flashcards
What does it mean that Apex is an integrated language?
That DML SOQL, SOSL are all integrated and can be used in the code.
What does it mean that Apex is a strongly typed language?
That variables must be declared with a datatype.
int a = 10;
Apex or Point and Click:
- Create Web services
- Create email services
- Perform complex validation over multiple objects
- Create complex business processes that are not supported by workflow
- Apex
- Apex
- Apex
- Apex
Apex or Point and Click:
Create custom transactional logic (logic that occurs over the entire transaction, not just with a single record or object)
Apex
Apex or Point and Click:
Attach custom logic to another operation, such as saving a record, so that it occurs whenever the operation is executed, regardless of whether it originates in the UI, a VF page or from the Web Services API.
Apex
True/False: All variables in Apex allow null as a value and are initialized to null if they are not assigned another value.
True.
In Apex, all variables and expressions have a data type. What are the five kinds of data types in Apex?
- Primitives (int, String)
- sObject
- Collections (Set, List, Map)
- Objects created from user-defined or system-defined apex classes
- Enums
True/False: Lists:
- Lists contain implicit keys, explicit values
- Is not ordered
- Values must be unique
- Useful for storing the results of a DB query
- True
- False - Lists have ordered values
- False
- True
True/False: Maps:
- Maps contain key, value - pairs
- Is not ordered
- Values must be unique
- Useful for caching records indexed by ID
- True
- True
- False - Keys must be unique
- True
True/False: Sets:
- Sets contain values
- Is not ordered
- Values must be unique
- Useful as a lookup criteria for relationship-based SOQL query
- True
- True
- True
- True
True/False: Lists can only contain Primitives and sObjects.
False.
Lists can contain Primitives, sObjects, objects created from Apex classes and collections.
True/False: Sets can only contain sObjects.
False.
Sets can only contain primitives.
True/False: the key, value pair of Maps can be:
- Primitive to Primitive
- Primitive to sObject
- Primitive to Collection
- True
- True
- True
Apex classes: What is the difference between:
- private myClass
- public myClass
- global myClass
- Classes cannot be referenced by any Apex code outside of the class in which they are defined.
- Classes can be called within the same org.
- Classes can be called by all Apex code everywhere. (e.g. webservices)
Apex classes: What is the difference between:
- public virtual myClass
- public abstract myClass
1. Apex supports virtual classes and methods. use "extend" to subclass a virtual class. Note, methods derived from a virtual class can be overridden, but doesn't have to be. 2. Apex supports abstract classes. Methods are defined, but implemented in the subclass. Note, methods derived from an abstract class must be overridden.
Apex classes: What is the difference between:
- public with sharing myClass
- public without sharing myClass
- With sharing or user context limits the code to access the records that the user executing the code has access to - respects the sharing model.
- Without sharing or system context - default - allows the code to access all records. - ignores the sharing model.
True/False: A class can only extend one other class, but can implement more than one interface.
True.
True/False: User-defined methods can be polymorphic.
True.
A method named myMethod can be implemented two times with a different number of parameters.
True/False: User-defined methods can be declared as static when defined in a Trigger.
False.
True/False: In Apex, all classes and methods are final by default. By default, classes may not be extended to create sub-classes, and methods may not be overridden within sub-classes.
True.
True/False: A class cannot have a more restrictive access modifier than one of its methods or attributes.
True.