Courseiva

CCNA Developer Fundamentals Questions

75 of 115 questions · Page 1/2 · Developer Fundamentals · Answers revealed

1
MCQeasy

A developer wants to retrieve the developer name of the current user's profile in Apex. Which object relationship should be queried via SOQL?

A.SELECT Name FROM Profile WHERE UserId = :UserInfo.getUserId()
B.SELECT Profile.Name FROM User WHERE Id = :UserInfo.getUserId()
C.SELECT ProfileId.Name FROM User WHERE Id = :UserInfo.getUserId()
D.SELECT ProfileName FROM User WHERE Id = :UserInfo.getUserId()
AnswerB

User records contain a Profile relationship, allowing traversal to the Profile Name field.

Why this answer

The User object relates to the Profile object through the ProfileId foreign key field.

2
MCQeasy

What is the primary purpose of the Model-View-Controller (MVC) design pattern implementation in Lightning Web Components (LWC)?

A.To convert Apex triggers into asynchronous jobs
B.To bypass Salesforce governor limits automatically
C.To separate data, user interface, and application logic into distinct components
D.To enforce field-level security without writing code
AnswerC

The MVC pattern isolates business logic from user interface presentation and data storage.

Why this answer

MVC separates application data (Model), user interface (View), and business logic/event handling (Controller) to promote modularity and maintainability.

3
Multi-Selecthard

Which THREE techniques help prevent hitting governor limits when writing SOQL queries in Apex? Choose 3 answers.

Select 3 answers
A.Omitting LIMIT clauses on large queries to ensure all records are fetched at once.
B.Filtering queries using indexed fields (such as Id, Name, or external IDs) where possible.
C.Querying records into lists rather than single sObject variables when multiple records match.
D.Using bind variables to pass collection criteria into SOQL WHERE clauses.
E.Placing SOQL queries inside helper methods called within loops.
AnswersB, C, D

Using indexed fields improves query performance and reduces CPU overhead.

Why this answer

Best practices include querying into collections, using bind variables, and filtering with indexed fields.

4
MCQmedium

A developer needs to retrieve Account records along with their associated Contacts in a single query. Which query syntax is correct?

A.SELECT Id, Name, CONCAT(Contacts) FROM Account
B.SELECT Id, Name, (SELECT Id, LastName FROM Contact) FROM Account
C.SELECT Id, Name, Contacts__r FROM Account
D.SELECT Id, Name, (SELECT Id, LastName FROM Contacts) FROM Account
AnswerD

This is the correct syntax for a child subquery in SOQL.

Why this answer

Parent-to-child subqueries use plural child relationship names enclosed in parentheses inside the SELECT clause.

5
MCQeasy

A developer needs to write an Apex trigger that fires before an Account is inserted and accesses the value of the custom field 'Rating__c'. Which collection type is best suited to iterate over the incoming records in the trigger context variable?

A.Account[]
B.List<Account>
C.Set<Account>
D.Map<Id, Account>
AnswerB

Trigger.new returns a List of sObjects, which can be directly iterated over using a List.

Why this answer

Trigger.new provides a List of sObjects, making a standard List or for-loop iteration the correct approach for handling trigger context records.

6
MCQmedium

A developer needs to convert a JSON string representing a list of Account records into an actual List<Account> in Apex. Which method should be used?

A.JSON.parse(jsonString)
B.(List<Account>) JSON.deserialize(jsonString, List<Account>.class)
C.List<Account>.parse(jsonString)
D.JSON.deserializeUntyped(jsonString)
AnswerB

JSON.deserialize requires the JSON string and the target type token (.class) to cast the result correctly.

Why this answer

JSON.deserialize() parses a JSON string into strongly typed Apex objects or collections.

7
MCQhard

A developer is writing a trigger on the Contact object that needs to reference old field values during an update operation. In which trigger context variable are these previous values stored?

A.Trigger.new
B.Trigger.previousValues
C.Trigger.newMap
D.Trigger.old
AnswerD

Trigger.old provides the pre-update state of the records during update and delete triggers.

Why this answer

Trigger.old contains a list of sObject records prior to the update or delete operation.

8
Multi-Selectmedium

Which TWO statements about SOQL relationship queries are true? Choose 2 options.

Select 2 answers
A.SOQL supports traversing up to 10 levels of parent relationships.
B.Parent-to-child queries use dot notation on the parent object.
C.Child-to-parent queries require subqueries.
D.Child-to-parent queries use dot notation (e.g., Account.Name).
E.Parent-to-child queries use a subquery inside parentheses.
AnswersD, E

Traversing from child to parent uses dot notation.

Why this answer

Parent-to-child queries use subqueries in parentheses, and child-to-parent queries use dot notation.

9
Multi-Selectmedium

Which TWO tools or features are part of the Model-View-Controller (MVC) architecture implementation in Salesforce declarative and programmatic development? Choose 2 answers.

Select 2 answers
A.Profiles and Permission Sets
B.Lightning Web Components and Visualforce pages
C.Salesforce Sharing Rules
D.Governor Limits
E.Custom Objects and Fields (Database schema)
AnswersB, E

UI frameworks like LWC and Visualforce act as the View layer.

Why this answer

Custom objects/database tables represent the Model, and Lightning components/Visualforce pages represent the View.

10
Multi-Selecthard

A developer implements a custom Apex controller for a Visualforce page that performs DML operations. Which THREE best practices should be followed to ensure robust data management and security? (Choose three.)

Select 3 answers
A.Check object CRUD and field-level security permissions before executing DML.
B.Handle DML exceptions properly using try-catch blocks or Database methods.
C.Enforce sharing rules by using 'with sharing' on the controller class.
D.Hardcode record type IDs directly in the controller class.
E.Bypass all triggers by using custom settings during Visualforce execution.
AnswersA, B, C

Validating user permissions prevents unauthorized data modifications.

Why this answer

Secure controllers must check CRUD/FLS, enforce sharing rules, and handle DML errors gracefully.

11
MCQmedium

A developer needs to update 5,000 Account records and wants to ensure that if any single record fails validation, none of the records are committed to the database. Which method should be used?

A.acctList.save()
B.Database.update(acctList, false)
C.Database.save(acctList, true)
D.update acctList;
AnswerD

Standard DML statements enforce an all-or-nothing atomic transaction model.

Why this answer

Standard DML statements (like update acctList;) are all-or-nothing operations. If any record fails, the entire transaction rolls back.

12
MCQhard

An application uses a SOSL search to find records across multiple objects. Which return type must be used to capture the results in Apex?

A.List<List<SObject>>
B.Map<String, List<SObject>>
C.SearchResult[]
D.List<SObject>
AnswerA

SOSL queries always return a list of lists, where each inner list contains the sObjects found for a specific sObject type.

Why this answer

SOSL search queries return a List of Lists of SObjects (List<List<SObject>>), because a single search can return results across multiple different sObject types.

13
Multi-Selectmedium

A developer is building a custom Lightning Web Component and wants to communicate data from a child component up to its parent component. Which THREE steps are required? (Choose three.)

Select 3 answers
A.Dispatch the event using the this.dispatchEvent() method in the child.
B.Import the wire service adapter in the parent component.
C.Use the @api decorator on a parent property inside the child component.
D.Create a new CustomEvent in the child component's JavaScript file.
E.Add an event listener directive (e.g., onmyevent) to the child component tag in the parent HTML template.
AnswersA, D, E

Dispatching the event sends it up the DOM tree to parent listeners.

Why this answer

Child-to-parent communication in LWC is achieved by creating and dispatching a CustomEvent from the child and listening for it on the parent's HTML template.

14
Multi-Selecthard

Which THREE actions can a developer take to optimize SOSL query performance and adhere to best practices? Choose 3 answers.

Select 3 answers
A.Use leading wildcards (e.g., '*Smith') to broaden search flexibility.
B.Target specific fields (e.g., EMAIL FIELDS) rather than searching ALL FIELDS.
C.Execute SOSL inside a tight for-loop over large data sets.
D.Specify the target sObject and fields to return to minimize data transfer.
E.Filter search results using logical operators like AND and OR.
AnswersB, D, E

Scoping the search to specific field lists reduces search overhead.

Why this answer

SOSL best practices include specifying the object and fields to return, targeting specific search text instead of leading wildcards, and restricting search scopes.

15
MCQhard

An Apex trigger needs to prevent records from being saved if a specific validation condition fails. How should the developer reject the DML operation on a specific record?

A.record.addError('Validation failed.');
B.Trigger.rollback();
C.ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Error'));
D.throw new ValidationException('Error');
AnswerA

Calling addError() on a record in Trigger.new prevents the DML operation for that record and reports the error.

Why this answer

Adding an error message to a record sObject in Trigger.new (e.g., record.addError('Message')) prevents that record from saving and adds an error to the UI/transaction.

16
Multi-Selecteasy

Which TWO methods are used to inspect sObject field metadata dynamically in Apex? Choose 2 options.

Select 2 answers
A.Schema.getGlobalDescribe()
B.System.describeFields()
C.Object.inspect()
D.Database.getMetadata()
E.SObjectType.getDescribe()
AnswersA, E

Returns a map of all sObject names to token types.

Why this answer

SObjectType.getDescribe() and Schema.getGlobalDescribe() are used for inspecting schema metadata.

17
MCQeasy

What is the return type of a SOQL query that returns a single aggregate result, such as SELECT COUNT() FROM Account?

A.AggregateResult
B.Decimal
C.List<SObject>
D.Integer
AnswerD

COUNT() queries return an Integer representing the total number of matching records.

Why this answer

A SOQL query using COUNT() without a GROUP BY clause returns an Integer representing the row count.

18
MCQhard

A developer is writing a batch Apex class. During the execute method, a record fails validation. The developer wants to ensure that successfully processed records in the same batch are committed while failing records are logged without aborting the entire batch. How should the DML be performed?

A.try-catch block around a standard insert statement
B.Database.upsert(records, true)
C.Database.insert(records, false)
D.Standard insert statement (e.g., insert records;)
AnswerC

Passing false for allOrNone enables partial success processing.

Why this answer

Using Database.insert(records, false) performs partial DML success, allowing valid records to commit while returning an array of save results for error handling.

19
MCQmedium

A developer needs to find all records across multiple objects (Contact, Lead, and Account) that contain the exact phrase 'Acme Corp'. Which feature should be used?

A.Database.query() with dynamic bindings
B.SOQL query with multiple WHERE clauses
C.SOSL FIND clause
D.Global Search API via REST
AnswerC

SOSL allows searching text across multiple objects using the FIND clause.

Why this answer

SOSL (Salesforce Object Search Language) is designed for text searches across multiple objects simultaneously.

20
Multi-Selecthard

Which THREE best practices should a developer follow when implementing CRUD and FLS checks in Apex? Choose 3 answers.

Select 3 answers
A.Rely solely on 'with sharing' keywords to handle field-level security checks.
B.Check sObject createability before performing insert DML operations.
C.Disable all triggers when performing security checks.
D.Check object updatability before committing updates to the database.
E.Use Schema describe methods to verify field accessibility before querying.
AnswersB, D, E

Verifying isCreateable ensures users have permission to create records.

Why this answer

Developers should check isAccessible, isCreateable, and isUpdateable using describe results before querying or saving data.

21
MCQhard

A developer is writing code that processes untrusted data and wants to automatically strip fields and relationships that the current user cannot access, without throwing an exception. Which feature should be used?

A.Security.stripInaccessible()
B.Database.insert(records, AccessType.ENFORCE_ACCESSIBLE)
C.Approval.lock()
D.Schema.sObjectType.fields.isAccessible()
AnswerA

stripInaccessible removes inaccessible fields and records gracefully.

Why this answer

The Security.stripInaccessible() method strips fields and SObjects that the user lacks permission to read or create/update, avoiding runtime security exceptions.

22
MCQeasy

Which Apex data type should a developer use to represent a precise geographic location with latitude and longitude coordinates?

A.Coordinate
B.Location
C.Address
D.GeoPoint
AnswerB

Location represents latitude and longitude coordinates.

Why this answer

The Location primitive data type in Apex is designed specifically to represent geographic locations with latitude and longitude.

23
MCQeasy

Which collection type stores elements as key-value pairs in Apex?

A.Set
B.Array
C.List
D.Map
AnswerD

Maps store elements as key-value pairs for rapid retrieval by key.

Why this answer

A Map stores key-value pairs where each unique key maps to a single value.

24
MCQhard

An Apex trigger executes during a bulk insert of 300 records. To adhere to best practices regarding governor limits and bulkification, how should SOQL queries be written?

A.Query inside a for-loop iterating over Trigger.new
B.Query each record individually using Limits.getQueries() checks
C.Use an asynchronous future method for every individual record
D.Query once outside the loop using a collection of IDs from Trigger.new
AnswerD

Bulkifying Apex code requires gathering IDs into collections and executing a single query outside of loops.

Why this answer

Queries must be written using bulkified collections, querying once outside of loops using bind variables for all records in Trigger.new.

25
MCQhard

A developer wants to ensure that a custom Apex REST service method properly handles authentication and executes securely in the context of the calling user. How should the class be defined?

A.webservice class without sharing
B.global class with sharing
C.public class with sharing
D.private class inherited sharing
AnswerB

Global accessibility is required for Apex REST endpoints, and with sharing enforces user context rules.

Why this answer

Apex REST services must be global classes, and specifying with sharing ensures sharing rules are respected.

26
MCQmedium

A developer is writing a SOQL query to find accounts where the billing country starts with 'United'. Which operator should be used?

A.LIKE 'United%'
B.MATCHES
C.STARTS_WITH
D.INCLUDES
AnswerA

LIKE with 'United%' matches strings starting with 'United'.

Why this answer

The LIKE operator is used in SOQL for wildcard matching, using '%' as the wildcard character.

27
Multi-Selecthard

A developer is writing an Apex trigger that needs to execute logic only when records are updated and a specific custom field 'Status__c' changes from 'Draft' to 'Submitted'. Which THREE elements are required to implement this check correctly? (Choose three.)

Select 3 answers
A.Use the Trigger.isInsert context variable to capture the initial draft creation.
B.Iterate through Trigger.old instead of Trigger.new.
C.Compare the prior status value with the new status value from Trigger.new.
D.Verify that the trigger context is either Trigger.isUpdate or check Trigger.isExecuting.
E.Access the prior value using Trigger.oldMap.get(record.Id).Status__c.
AnswersC, D, E

Comparing old and new field values confirms whether a transition took place.

Why this answer

Checking for field value changes across update contexts requires comparing Trigger.oldMap with Trigger.new and checking the specific context.

28
MCQeasy

Which SOQL aggregate function should a developer use to count the exact number of rows returned by a query without retrieving the records into memory?

A.COUNT()
B.TOTAL()
C.SUM()
D.SIZE()
AnswerA

COUNT() returns the total number of matching records.

Why this answer

The COUNT() function returns the number of rows matching the query criteria efficiently as an integer.

29
Multi-Selecteasy

Which TWO methods are available on the Database class for performing DML operations with partial success capability? Choose 2 options.

Select 2 answers
A.Database.save()
B.Database.commit()
C.Database.persist()
D.Database.update()
E.Database.insert()
AnswersD, E

Supports partial success via allOrNone parameter.

Why this answer

Database.insert() and Database.update() accept an allOrNone boolean parameter allowing partial success.

30
MCQmedium

A developer needs to retrieve 10 Account records starting from the 21st record to implement pagination in a custom component. Which SOQL clause should be used?

A.LIMIT 10 OFFSET 20
B.LIMIT 20 OFFSET 10
C.RANGE 20 TO 30
D.SKIP 20 TAKE 10
AnswerA

LIMIT 10 restricts results to 10 records, and OFFSET 20 skips the first 20 records.

Why this answer

SOQL supports pagination using LIMIT and OFFSET clauses.

31
MCQmedium

A developer needs to dynamically instantiate an sObject type based on a string variable representing the object name (e.g., 'Account'). Which method should be used?

A.Schema.getGlobalDescribe().get('Account').newSObject()
B.Type.forName('Account').newInstance()
C.Database.load('Account')
D.SObject.createInstance('Account')
AnswerA

This method retrieves the token from global describe and instantiates a new sObject instance dynamically.

Why this answer

Schema.getGlobalDescribe().get('Account').newSObject() allows dynamic sObject creation from a string object name.

32
MCQmedium

A developer needs to ensure that an Apex class respects organization-wide defaults, role hierarchies, and sharing rules when querying custom objects. Which keyword should be added to the class definition?

A.enforce sharing
B.with sharing
C.without sharing
D.inherited sharing
AnswerB

Enforces record-level security and sharing rules.

Why this answer

The with sharing keyword enforces sharing rules of the current user, while without sharing runs in system mode.

33
Multi-Selectmedium

Which TWO features are characteristics of SOSL (Salesforce Object Search Language) queries? Choose 2 answers.

Select 2 answers
A.SOSL returns a single flat List of SObjects.
B.SOSL queries can update existing records directly.
C.SOSL queries are limited to a maximum of 10 records per search.
D.SOSL can search across multiple sObjects and fields in a single query.
E.SOSL tokenizes search terms to perform optimized text matching.
AnswersD, E

SOSL is designed for text searches across multiple object types simultaneously.

Why this answer

SOSL searches text across multiple objects and fields simultaneously and can tokenize words for matching.

34
MCQmedium

A developer needs to retrieve a list of Accounts along with their related Contacts using a single SOQL query in Apex. Which query structure is syntactically correct?

A.SELECT Id, Name, Contacts.Id, Contacts.LastName FROM Account
B.SELECT Id, Name, Contact__r.Name FROM Account
C.SELECT Id, Name, (SELECT Id, LastName FROM Contact) FROM Account
D.SELECT Id, Name, (SELECT Id, LastName FROM Contacts) FROM Account
AnswerD

This represents a valid parent-to-child relationship query using a subquery for the child relationship name.

Why this answer

Parent-to-child relationships in SOQL are queried using a subquery within parentheses inside the SELECT clause.

35
MCQeasy

What is the correct way to declare a constant variable in Apex?

A.static readonly Integer MAX_COUNT = 10;
B.final Integer MAX_COUNT = 10;
C.immutable Integer MAX_COUNT = 10;
D.const Integer MAX_COUNT = 10;
AnswerB

final defines a variable that can only be assigned once.

Why this answer

Constants in Apex are declared using the final keyword combined with static.

36
Multi-Selecthard

Which THREE operations will cause an immediate transaction rollback or DML failure when utilizing standard DML statements in Apex? Choose 3 answers.

Select 3 answers
A.A record failing a validation rule triggered by the DML operation.
B.Updating a record that has already been committed in the database.
C.Using the Database.insert(list, false) method with a failing record.
D.Calling record.addError() inside a trigger context.
E.Exceeding the maximum heap size limit during processing.
AnswersA, D, E

Validation rule failures cause the entire standard DML transaction to roll back.

Why this answer

Uncaught exceptions, hit governor limits, or triggering record-level validation errors via addError() will fail the transaction or records.

37
MCQeasy

Which Apex data type is best suited for storing monetary amounts with high precision?

A.Decimal
B.Double
C.String
D.Integer
AnswerA

Decimal is precise and is the standard type used for currency fields in Salesforce.

Why this answer

The Decimal data type is used for currency and precise numerical calculations in Apex.

38
MCQeasy

What is the correct file extension for an Apex class created in Salesforce DX?

A..apex
B..controller
C..cls
D..trigger
AnswerC

Apex classes use the .cls extension.

Why this answer

Apex class files use the .cls extension, accompanied by a .cls-meta.xml metadata file.

39
MCQeasy

A developer wants to retrieve up to 5 recently viewed records of any object type using SOSL. Which SOSL clause specifies the maximum number of records to return?

A.TOP 5
B.MAX 5
C.LIMIT 5
D.ROWS 5
AnswerC

The LIMIT clause restricts the number of rows returned by a SOSL query.

Why this answer

SOSL search results can be limited using the LIMIT clause at the end of the query statement.

40
MCQmedium

A developer writes a SOQL query to aggregate total opportunity amounts grouped by stage name. Which SOQL clause is required?

A.HAVING BY
B.GROUP BY
C.AGGREGATE BY
D.ORDER BY
AnswerB

GROUP BY is required when aggregating data by specific fields.

Why this answer

Aggregate queries in SOQL require the GROUP BY clause when using functions like SUM(), COUNT(), or AVG().

41
Multi-Selectmedium

Which TWO data types can be used as keys in an Apex Map? Choose 2 answers.

Select 2 answers
A.Blob
B.Id
C.List<String>
D.SObject
E.String
AnswersB, E

IDs are frequently used as map keys for sObject mapping.

Why this answer

Primitive data types like String, ID, and Integer can be used as map keys in Apex.

42
Multi-Selectmedium

A developer is writing an Apex trigger and needs to optimize performance and prevent governor limit violations. Which TWO practices should the developer follow? (Choose two.)

Select 2 answers
A.Place DML statements inside 'for' loops to ensure immediate database commits.
B.Use the 'webservice' keyword on helper methods called by triggers.
C.Execute a separate SOQL query for every single record in Trigger.new.
D.Use trigger context variables like Trigger.new to process records in bulk.
E.Perform SOQL queries and DML operations outside of loops.
AnswersD, E

Trigger context variables hold collections of sObjects, allowing batch processing of records.

Why this answer

Triggers must be bulkified to handle collections of records and queries/DML operations must be kept outside loops.

43
MCQmedium

A developer needs to ensure that a custom Apex controller safely checks whether the current user has read access to the 'Salary__c' field on the 'Employee__c' object before displaying it in a Lightning Web Component. Which method should the developer use?

A.Employee__c.Salary__c.getDescribe().isCreateable()
B.User.hasReadAccess('Employee__c', 'Salary__c')
C.Schema.sObjectType.Employee__c.fields.Salary__c.isAccessible()
D.ApexPages.currentPage().getParameters().get('Salary__c')
AnswerC

The isAccessible() method on the field describe result returns true if the current user has read access to the field.

Why this answer

The Security class and sObjectDescribe methods provide mechanisms to check CRUD and FLS in Apex before querying or displaying data.

44
MCQeasy

What is the maximum number of SOQL queries that can be issued in a single synchronous Apex transaction?

A.200
B.100
C.50000
D.50
AnswerB

Salesforce permits a maximum of 100 SOQL queries in a synchronous transaction.

Why this answer

The synchronous governor limit for SOQL queries is 100.

45
MCQeasy

A developer wants to define a constant value in an Apex class that can be accessed globally without instantiating the class. Which combination of keywords should be used?

A.protected static
B.public static final
C.private volatile
D.global transient
AnswerB

'static' associates the variable with the class, and 'final' ensures it acts as a constant once initialized.

Why this answer

Constants in Apex are defined using the 'static' and 'final' keywords to ensure they belong to the class and cannot be modified.

46
Multi-Selectmedium

Which TWO statements are true regarding the behavior of Apex triggers and context variables? Choose 2 answers.

Select 2 answers
A.Trigger.old is available in update and delete triggers.
B.Trigger.new is available in insert, update, and undelete triggers.
C.Trigger.old is available in insert and update triggers.
D.Trigger.new records are always read-only in before triggers.
E.Trigger.newMap is available in before insert triggers.
AnswersA, B

Trigger.old holds pre-update and pre-delete record states.

Why this answer

Trigger.new is available on insert, update, and undelete. Trigger.old is available on update and delete.

47
Multi-Selecteasy

Which THREE collections are available in Apex? (Choose three.)

Select 3 answers
A.Queue
B.Set
C.Table
D.List
E.Map
AnswersB, D, E

Set is a fundamental collection type in Apex.

Why this answer

Apex provides three built-in collection types: List, Set, and Map.

48
MCQeasy

Which collection method is used to add all elements from one Set into another Set in Apex?

A.addAll()
B.merge()
C.combine()
D.putAll()
AnswerA

addAll() adds all elements of a collection to the target set.

Why this answer

The addAll() method is available on Set, List, and Map collections to add multiple elements at once.

49
MCQhard

An Apex trigger needs to prevent duplicate records from being inserted based on a custom external ID field. Which approach should the developer take to optimize query performance and respect governor limits?

A.Use Database.upsert with strict mode enabled inside the trigger loop.
B.Query the database inside a for loop for every record in Trigger.new.
C.Collect the external ID values into a Set, query once outside the loop, and use a Map for validation.
D.Use an asynchronous @future method to validate duplicates after insert.
AnswerC

This is fully bulkified and avoids governor limit violations.

Why this answer

Collecting field values into a Set, querying existing records matching that Set in a single query outside of loops, and comparing in memory is the bulkified approach.

50
Multi-Selecthard

Which THREE factors can cause an Apex CPU time limit exception in a synchronous transaction? Choose 3 answers.

Select 3 answers
A.Executing nested loops over large collections of sObjects.
B.Running complex string manipulations or regular expression matching on large text bodies.
C.Invoking too many SOQL queries within the 100 query limit.
D.Exceeding the total number of allowed DML statements.
E.Executing heavy calculations inside triggers processing large bulk record batches.
AnswersA, B, E

Nested loops with high iteration counts rapidly consume CPU time.

Why this answer

Heavy loops, complex triggers, inefficient nested queries or collections processing, and excessive regex or string manipulations contribute to CPU time exhaustion.

51
MCQmedium

A developer needs to assign a default value to a custom picklist field via Apex when creating a Lead record. What data type should be assigned to the picklist field in Apex?

A.String
B.Boolean
C.PicklistEntry
D.Integer
AnswerA

Picklist values are represented as String types in Apex sObject assignments.

Why this answer

Picklist fields in Salesforce are represented as Strings in Apex when assigned or retrieved via sObjects.

52
Multi-Selecthard

Which THREE tools or contexts can be used to execute Anonymous Apex code? Choose 3 options.

Select 3 answers
A.Salesforce CLI (sf apex run)
B.Standard Page Layout Editor
C.Developer Console
D.Salesforce Extensions for Visual Studio Code
E.Lightning App Builder
AnswersA, C, D

SF CLI supports running anonymous apex scripts.

Why this answer

Anonymous Apex can be executed via the Developer Console, Salesforce Extensions for VS Code, and Salesforce CLI (sf apex run).

53
Multi-Selecteasy

Which TWO statements about Apex variables and initialization are true? Choose 2 options.

Select 2 answers
A.Every variable in Apex must be explicitly declared with its data type.
B.Unassigned primitive variables are automatically initialized to null.
C.Integer variables default to 1 if unassigned.
D.Apex supports dynamic duck typing without variable declarations.
E.Boolean variables default to true if unassigned.
AnswersA, B

Apex is a strongly typed language requiring explicit data type declarations.

Why this answer

Unassigned primitive variables default to null, and variables must be declared with a type before use.

54
MCQeasy

A developer needs to store a collection of Account IDs where duplicates are automatically prevented and lookups are extremely fast. Which collection type should the developer use?

A.Map<Id, Id>
B.Queue<Id>
C.List<Id>
D.Set<Id>
AnswerD

Sets inherently prevent duplicate entries and offer optimal performance for membership checks.

Why this answer

Sets in Apex store unique elements and provide very fast lookups by value using methods like contains().

55
Multi-Selecthard

Which THREE operations can cause an automatic roll back of an entire Apex transaction? Choose 3 options.

Select 3 answers
A.Catching a DmlException inside a try-catch block.
B.Executing Database.insert(records, false) with partial failure.
C.Exceeding a governor limit such as SOQL query count.
D.A DML failure when allOrNone defaults to true (or standard DML syntax).
E.An unhandled exception occurring anywhere in the execution stack.
AnswersC, D, E

Governor limit violations immediately terminate and roll back transactions.

Why this answer

Unhandled exceptions, unhandled DML errors with allOrNone=true, and governor limit violations roll back the transaction.

56
MCQmedium

A developer needs to convert a JSON string representing a list of Account objects into an actual Apex List of Accounts. Which method should be used?

A.JSON.deserialize(jsonString, List<Account>.class)
B.String.valueOf(jsonString)
C.JSON.serialize()
D.JSON.parse()
AnswerA

This correctly parses the JSON string into a typed List of Accounts.

Why this answer

JSON.deserialize() or JSON.deserializeUntyped() are used to parse JSON, and JSON.deserialize(jsonString, TargetType.class) deserializes into strongly typed objects.

57
MCQmedium

A developer has written an Apex method that executes a SOQL query to retrieve all Contacts associated with an Account. The method needs to be invoked securely without bypassing the user's organization-wide defaults and sharing settings. How should the developer execute this query?

A.Include the 'WITH SECURITY_ENFORCED' clause in the SOQL query.
B.Define the class using the 'with sharing' keyword.
C.Execute the query within a @future method.
D.Use the Schema.describeSObjects method before querying.
AnswerB

Adding 'with sharing' to the class definition ensures that the executing user's sharing rules are enforced during SOQL operations.

Why this answer

By default, SOQL queries executed in Apex enforce user-level sharing rules unless the 'with sharing' keyword is explicitly omitted in a 'without sharing' class context.

58
MCQeasy

A developer needs to check if a specific key exists in a Map<String, Decimal> before retrieving its value. Which Map method should be used?

A.containsKey()
B.hasKey()
C.contains()
D.exists()
AnswerA

containsKey() checks for the presence of a key and returns a boolean value.

Why this answer

The containsKey() method checks whether a specified key exists in a Map instance.

59
MCQhard

An enterprise application requires Apex code to check whether the current user has read access to a specific custom field before displaying it in a custom Lightning Web Component. What is the most appropriate class to use?

A.System.Security
B.Schema.DescribeFieldResult
C.UserInfo
D.ApexPages.StandardController
AnswerB

DescribeFieldResult provides methods to evaluate user access permissions on fields.

Why this answer

The Schema.DescribeFieldResult class provides methods like isAccessible() to check Field-Level Security (FLS) dynamically.

60
MCQeasy

Which tool or feature in Salesforce Developer Console allows a developer to inspect debug logs and filter them by category and level?

A.Checkpoints
B.Log Inspector
C.Query Editor
D.Anonymous Apex
AnswerB

Log Inspector allows in-depth analysis of debug logs.

Why this answer

The Logs tab in the Developer Console displays execution logs, and Log Inspector provides detailed analysis tools.

61
Multi-Selecthard

Which THREE best practices should a developer follow to avoid governor limits when writing SOQL queries in Apex? Choose 3 options.

Select 3 answers
A.Query only the specific fields needed rather than using SELECT *.
B.Avoid placing SOQL queries inside loops.
C.Use bind variables to parameterize query criteria.
D.Execute a separate SOQL query for every child record individually.
E.Always use SELECT FIELDS(ALL) to ensure all data is retrieved.
AnswersA, B, C

Selecting only required fields reduces heap usage and improves performance.

Why this answer

Best practices include avoiding queries inside loops, using bind variables, and querying only necessary fields.

62
MCQeasy

Which Salesforce data model relationship type allows two objects to have a many-to-many relationship through a junction object?

A.Hierarchical Relationship
B.Master-Detail Relationship
C.Lookup Relationship
D.External Relationship
AnswerB

A junction object uses two Master-Detail relationships to connect two parent objects in a many-to-many relationship.

Why this answer

Master-Detail relationships on a junction object pointing to two parent objects establish a many-to-many relationship.

63
MCQeasy

What is the maximum number of SOQL queries that can be issued in a single synchronous Apex transaction?

A.50
B.200
C.100
D.500
AnswerC

Synchronous transactions allow a maximum of 100 SOQL queries.

Why this answer

The synchronous governor limit for SOQL queries is 100 queries per transaction.

64
MCQhard

A developer creates a custom Lightning Web Component that includes a wired property to retrieve account records. The component needs to react dynamically when the record data is updated via another component on the page. Which decorator should be used on the JavaScript property to receive reactive updates?

A.@api
B.@wire
C.@track
D.@readonly
AnswerB

@wire connects a property or function to a Salesforce wire service adapter, updating reactively when underlying data changes.

Why this answer

The @wire decorator in Lightning Web Components provisions a stream of data to a property or function reactively.

65
MCQhard

An Apex trigger invokes a helper method that performs a DML operation, but the developer wants to establish a rollback point so that prior changes can be reverted if a subsequent error occurs. Which feature should be used?

A.Approval.lock()
B.System.createCheckpoint()
C.Database.Savepoint sp = Database.setSavepoint();
D.Database.beginTransaction()
AnswerC

Savepoints allow partial rollbacks within a transaction.

Why this answer

Database.setSavepoint() creates a savepoint, and Database.rollback() rolls back changes to that savepoint.

66
MCQhard

A developer needs to determine if the current user has delete permissions on the Opportunity object in Apex before calling a deletion method. Which method should be used?

A.User.hasPermission('Opportunity', 'Delete')
B.System.hasDeleteAccess(Opportunity.class)
C.Schema.sObjectType.Opportunity.isDeletable()
D.Opportunity.sObjectType.getDescribe().isDeletable()
AnswerC

Schema.sObjectType.Opportunity.isDeletable() correctly verifies object-level delete permissions.

Why this answer

Schema.sObjectType.Opportunity.isDeletable() checks if the current user has delete permission on the Opportunity object.

67
MCQmedium

A developer needs to convert a String variable containing a numeric value into an Integer in Apex. Which method should be used?

A.String.toInteger()
B.Convert.toInteger()
C.Integer.valueOf()
D.Integer.parse()
AnswerC

valueOf() parses strings into numeric primitives.

Why this answer

Integer.valueOf() converts a String representation of a number into an Integer primitive.

68
MCQeasy

Which method is used to get the number of elements in an Apex List?

A.getNumElements()
B.size()
C.length()
D.count()
AnswerB

size() returns the element count for collections.

Why this answer

The size() method returns the number of elements in a List, Set, or Map in Apex.

69
Multi-Selecteasy

Which TWO primitive data types are natively supported in Apex? Choose 2 options.

Select 2 answers
A.Char
B.Structure
C.Array
D.Integer
E.Boolean
AnswersD, E

Integer is a valid Apex primitive.

Why this answer

Integer and Boolean are native primitive data types in Apex, whereas Array and Structure are not standalone primitive types.

70
Multi-Selectmedium

Which TWO statements about SOSL (Salesforce Object Search Language) are true? Choose 2 options.

Select 2 answers
A.SOSL can only query a single object per statement.
B.SOSL can query text across multiple standard and custom objects in a single query.
C.SOSL search results return a list of lists of sObjects.
D.SOSL queries support complex arithmetic calculations and grouping clauses.
E.SOSL queries are executed using the SELECT keyword.
AnswersB, C

SOSL is optimized for cross-object text searches.

Why this answer

SOSL searches across multiple objects and returns lists of sObjects grouped by object type.

71
Multi-Selectmedium

Which TWO statements are true regarding the Salesforce security model and Apex execution context? Choose 2 answers.

Select 2 answers
A.Apex code runs in system mode by default, ignoring object and field-level permissions.
B.System mode ignores record-level sharing rules and user permissions entirely.
C.Apex code automatically enforces sharing rules unless declared 'without sharing'.
D.The 'with sharing' keyword enforces record-level sharing rules.
E.Profile permissions always override Apex system mode execution.
AnswersA, D

By default, Apex has access to all objects and fields regardless of user permissions.

Why this answer

Apex runs in system mode by default (ignoring FLS and CRUD), and sharing rules are only enforced if 'with sharing' is declared.

72
Multi-Selecteasy

Which TWO collection interfaces or classes are provided in Apex? Choose 2 options.

Select 2 answers
A.Vector
B.Dictionary
C.Hashtable
D.Map
E.List
AnswersD, E

Map is a built-in Apex collection.

Why this answer

List and Map are core collection types in Apex.

73
MCQeasy

Which collection type in Apex stores elements as key-value pairs where each key maps to a single value?

A.Set
B.Queue
C.Map
D.List
AnswerC

Maps store associations between keys and values.

Why this answer

A Map stores key-value pairs where each unique key maps to a single value.

74
MCQhard

An Apex trigger processes a list of Case records. The developer wants to group the cases by their AccountId. Which data structure is best suited for this grouping?

A.List<Map<Id, Case>>
B.Set<Map<Id, Case>>
C.Map<Id, Case>
D.Map<Id, List<Case>>
AnswerD

This structure supports multiple cases per AccountId.

Why this answer

A Map where the key is the AccountId (Id) and the value is a List of Cases (List<Case>) allows efficient grouping of child records by parent ID.

75
MCQmedium

A developer needs to query Task records related to Account records using a parent-to-child relationship. What is the standard child relationship name for Tasks on the Account object?

A.AccountTasks
B.ActivityHistories
C.ChildTasks
D.Tasks
AnswerD

Tasks is the standard child relationship name for task subqueries.

Why this answer

The standard child relationship name for Tasks on Account is OpenActivities and ActivityHistories or Tasks depending on the exact context, but Tasks is standard for custom/standard queries using Tasks relationship name.

Page 1 of 2 · 115 questions totalNext →

Ready to test yourself?

Try a timed practice session using only Developer Fundamentals questions.