SalesforceSalesforce DeveloperPlatform Developer IEasy
What are the main data types and collection types in Apex?
Suggested answer
Apex primitive types: Integer, Long, Decimal, Double, Boolean, String, Id, Date, Datetime, Time, Blob. Collections:
1. List: Ordered, index-accessible, allows duplicates. List<Account> accts = new List<Account>();
2. Set: Unordered, no duplicates, used for uniqueness checks and deduplication. Set<Id> ids = new Set<Id>();
3. Map: Key-value pairs with unique keys. Map<Id, Account> accMap = new Map<Id, Account>([SELECT Id, Name FROM Account]); Collections are essential for bulkification — collect IDs in Sets, query once into Maps, and batch DML into Lists to avoid governor limits.
Practice content for interview preparation; not an official vendor answer. Verify details against current product documentation.
Community comments (0)
No comments yet.
Sign in or create a free account to add a comment. Comments are moderated before they appear.