Application Development & Apex Flashcards
Q. What is Apex in Salesforce?
A. Apex is a strongly-typed, object-oriented programming language used for executing business logic and transaction control in Salesforce.
Q. What programming languages is Apex similar to?
A. Apex is similar to Java and C#.
Q. Where is Apex code executed?
A. Apex code runs on Salesforce’s multi-tenant cloud infrastructure.
Q. What are the key features of Apex?
- Object-oriented programming
- Strongly typed language
- Integrated with Salesforce database
- Bulk processing support
- Transactional control
Q. What are the primitive data types in Apex?
A. Integer, Double, Long, Date, DateTime, Boolean, String, Blob, and ID.
Q. How do you define a class in Apex?
public class MyClass {
public String myVariable;
public void myMethod() { System.debug('Hello Apex'); } }
Q. What are collections in Apex?
A. Collections in Apex include Lists, Sets, and Maps.
Q. What is the difference between Lists, Sets, and Maps in Apex?
- Lists: Ordered collection allowing duplicates.
- Sets: Unordered collection that does not allow duplicates.
- Maps: Key-value pairs for fast lookup.
Q. How do you declare a List in Apex?
List<String> myList = new List<String>{'Apple', 'Banana', 'Cherry'};</String></String>
Q. What is an Apex trigger?
A. A trigger is Apex code that runs before or after a record is inserted, updated, deleted, or undeleted.
Q. What are the two types of triggers in Salesforce?
A. Before triggers (modify records before saving) and After triggers (access record values after saving).
Q. What is a bulkified trigger?
A. A trigger designed to process multiple records efficiently to avoid governor limits.
Q. What is an example of a basic Apex trigger?
trigger AccountTrigger on Account (before insert, before update) {
for (Account acc : Trigger.new) {
acc.Name = acc.Name + ‘ - Updated’;
}
}
Q. How do you prevent recursion in Apex triggers?
A. By using static variables in a helper class.
Q. What is SOQL?
A. Salesforce Object Query Language (SOQL) is used to query records from Salesforce objects.