Are you preparing for the DEV-501: Apex and Visualforce Controllers certification exam? Look no further! Exam Sage presents a comprehensive, expertly crafted practice exam designed to sharpen your skills and boost your confidence for this critical Salesforce developer certification.
What is the DEV-501 Exam?
The DEV-501 exam focuses on your ability to design, build, and implement Apex classes and Visualforce controllers that meet business needs within the Salesforce platform. This exam tests your understanding of Apex programming concepts, controller types, Visualforce page development, security best practices, and advanced controller functionalities.
What You Will Learn
With this practice exam, you will deepen your knowledge of essential Apex and Visualforce topics, including:
Apex controller types: standard controllers, custom controllers, and controller extensions
Visualforce page construction and dynamic data binding
Handling View State for optimized page performance
SOQL and SOSL querying, including best practices to avoid SOQL injection
Asynchronous Apex features like Queueable and future methods
Apex testing strategies and test data management
Exception handling and user-friendly error messaging
Lightning integration and exposing Apex methods to Lightning components
Pagination with StandardSetController
Salesforce security with sharing rules and field-level security enforcement
Why Choose Exam Sage’s Practice Exam?
Our DEV-501 Practice Exam contains 530 high-quality, up-to-date multiple-choice questions, crafted by Salesforce experts to mirror the real exam’s difficulty and scope. Each question comes with detailed explanations to help you understand the underlying concepts and reasoning, making your study time more effective and focused.
Realistic exam simulation: Build confidence with questions modeled after the actual DEV-501 exam format.
In-depth explanations: Learn not just the ‘what’ but the ‘why’ behind each answer.
Covers all key topics: From Apex fundamentals to advanced Visualforce controllers and security best practices.
Optimized for success: Improve your exam readiness with thorough topic coverage and expert insights.
How Exam Sage Helps You Succeed
ExamSage.com is your trusted source for top-tier practice exams tailored to help you master complex certifications like Salesforce DEV-501. Our platform offers:
Easy-to-use interface for seamless practice
Instant feedback with correct answers and detailed explanations
Accessible anywhere, anytime on any device
Continuous updates to reflect Salesforce platform changes and exam updates
Get Ready to Pass the DEV-501 Exam with Confidence
Whether you are a Salesforce developer looking to validate your skills or aiming to enhance your career prospects, the DEV-501: Apex and Visualforce Controllers Practice Exam from Exam Sage is your ultimate preparation tool. Start practicing today and take the next step towards becoming a certified Salesforce developer!
Sample Questions and Answers
1. What is a key difference between a standard controller and a custom controller in Visualforce?
A) Standard controllers require Apex code
B) Custom controllers cannot access standard objects
C) Standard controllers automatically enforce CRUD and FLS
D) Custom controllers are more secure than standard controllers
Answer: C
Explanation: Standard controllers automatically enforce CRUD (Create, Read, Update, Delete) and Field-Level Security (FLS), whereas custom controllers require manual handling of these security aspects.
2. What method is required in a custom controller or extension to allow pagination?
A) setRecords()
B) getPage()
C) next()
D) getPagination()
Answer: C
Explanation: The next()
method is typically part of a pagination controller used to navigate to the next page in a custom pagination logic.
3. Which annotation in Apex is used to expose a method to Lightning or external systems via REST?
A) @AuraEnabled
B) @InvocableMethod
C) @RemoteAction
D) @WebService
Answer: A
Explanation: @AuraEnabled
is used to expose Apex methods to Lightning components and external systems using REST API.
4. In a custom controller, how can you prevent users from accessing unauthorized records?
A) Enable View All Records
B) Use dynamic SOQL
C) Check with with sharing
and enforce CRUD/FLS
D) Use static SOQL
Answer: C
Explanation: Using with sharing
ensures record-level security is enforced. Additionally, developers must manually check CRUD/FLS.
5. Which keyword is required to allow a Visualforce page to run in system context without sharing rules?
A) without security
B) without context
C) without sharing
D) no sharing
Answer: C
Explanation: The without sharing
keyword in Apex allows the controller to execute in system context, ignoring sharing rules.
6. Which controller type is best suited when building a Visualforce page for a custom business logic process?
A) Standard controller
B) Controller extension
C) Custom controller
D) Apex trigger
Answer: C
Explanation: Custom controllers offer full control over logic, making them suitable for complex or custom business workflows.
7. Which method is automatically available in a standard controller in Visualforce?
A) getData()
B) save()
C) doSave()
D) run()
Answer: B
Explanation: Standard controllers provide default methods like save()
, delete()
, etc., to perform basic operations.
8. What is the purpose of a controller extension in Visualforce?
A) Replace the standard controller
B) Add functionality to standard/custom controllers
C) Restrict user access
D) Override Visualforce rendering
Answer: B
Explanation: Controller extensions are used to extend or enhance the behavior of standard/custom controllers.
9. How is a Visualforce page linked to a custom controller?
A) Using the extensions
attribute
B) Using the controller
attribute
C) Through Apex trigger
D) Via JavaScript
Answer: B
Explanation: The controller
attribute in the <apex:page>
tag links the page to a custom controller class.
10. What happens if an Apex class uses “without sharing”?
A) Enforces sharing rules
B) Ignores all CRUD permissions
C) Ignores record-level sharing rules
D) Disables Apex functionality
Answer: C
Explanation: “without sharing” bypasses sharing rules, allowing access to records regardless of the user’s access level.
11. Which Visualforce component supports rendering lists with pagination?
A) <apex:inputText>
B) <apex:outputPanel>
C) <apex:pageBlockTable>
D) <apex:repeat>
Answer: C
Explanation: <apex:pageBlockTable>
supports list rendering and works well with pagination controls.
12. What is a best practice for handling exceptions in Apex controllers?
A) Ignore them
B) Use try-catch blocks
C) Log them using System.debug
only
D) Show raw exception messages to users
Answer: B
Explanation: Try-catch blocks handle exceptions and allow developers to log errors and show user-friendly messages.
13. How can you expose an Apex method to JavaScript in a Visualforce page?
A) Use @RemoteAction
B) Use @AuraEnabled
C) Use @WebService
D) Use @InvocableMethod
Answer: A
Explanation: @RemoteAction
allows Apex methods to be called from JavaScript in a Visualforce page.
14. Which governor limit is most relevant when writing Apex in controllers?
A) Maximum number of Apex classes
B) Number of concurrent users
C) SOQL queries per transaction
D) Visualforce page size
Answer: C
Explanation: Salesforce enforces limits like 100 SOQL queries per transaction to ensure performance and stability.
15. What is the default context for execution of Apex code?
A) User context
B) System context
C) Admin context
D) Sharing context
Answer: B
Explanation: Apex code runs in system context by default, except for anonymous blocks and controllers marked with sharing
.
16. What is the result of using Database.insert(sObject, false)
?
A) Performs a partial DML
B) Ignores sharing rules
C) Allows rollbacks
D) Fails silently
Answer: A
Explanation: The false
flag performs partial DML. If some records fail, others still commit.
17. What Visualforce tag is used to pass parameters to controllers?
A) <apex:variable>
B) <apex:param>
C) <apex:inputParam>
D) <apex:pageParam>
Answer: B
Explanation: <apex:param>
is used to pass parameters from Visualforce components to controller methods.
18. Which method allows you to retrieve URL parameters in Apex?
A) ApexPages.getUrl()
B) getParameter()
C) ApexPages.currentPage().getParameters().get()
D) getQueryParam()
Answer: C
Explanation: ApexPages.currentPage().getParameters().get('paramName')
is the standard way to access URL parameters.
19. How do you enforce FLS in Apex code?
A) Use with sharing
B) Enable CRUD check in UI
C) Manually check with Schema.DescribeFieldResult
D) Use @AuraEnabled
Answer: C
Explanation: Developers must manually check field accessibility using Schema.DescribeFieldResult.isAccessible()
.
20. When should you use controller extensions over custom controllers?
A) When extending standard controller functionality
B) When full control is needed
C) When creating REST endpoints
D) When overriding triggers
Answer: A
Explanation: Extensions are best when you need to add logic to existing standard controllers.
21. How can you bind a Visualforce input field to a custom controller variable?
A) Using the id
attribute
B) Using the label
attribute
C) Using value="{!controllerVariable}"
D) Using bind="{!controllerVariable}"
Answer: C
Explanation: The value
attribute binds the input field to a controller variable.
22. Which Apex class allows you to manually construct and render a page?
A) PageReference
B) VisualforceRenderer
C) ApexPages.Page
D) ApexRenderEngine
Answer: A
Explanation: PageReference
allows redirection or rendering of pages programmatically.
23. Which Visualforce tag renders based on a condition?
A) <apex:if>
B) <apex:rendered>
C) <apex:visible>
D) <apex:condition>
Answer: B
Explanation: The rendered
attribute in most Visualforce tags can conditionally show/hide content.
24. What is true about Apex controller constructors?
A) Must return a Boolean
B) Are always static
C) Cannot accept parameters
D) Are used to initialize variables
Answer: D
Explanation: Constructors in controllers initialize state and variables before rendering the page.
25. Which method is typically used to navigate to another page from a controller?
A) Page.navigate()
B) PageReference.setPage()
C) return Page.pageName
D) goToPage()
Answer: C
Explanation: Returning a PageReference
like return Page.YourPage;
in an Apex method allows navigation.
26. What kind of controller supports Visualforce email templates?
A) Custom Controller
B) StandardSetController
C) Standard Controller
D) Custom Extension
Answer: C
Explanation: Standard controllers are used in Visualforce email templates to access record data.
27. What is the primary purpose of StandardSetController?
A) To handle page-level rendering
B) To manage multiple records with pagination
C) To handle user permissions
D) To send email notifications
Answer: B
Explanation: StandardSetController
allows operations on a list of records, supporting pagination and bulk actions.
28. Which object allows access to the current page and its parameters?
A) PageController
B) ApexContext
C) ApexPages
D) CurrentPageContext
Answer: C
Explanation: ApexPages
provides access to the current page context, including parameters and messages.
29. What happens if a Visualforce controller does not have a getter for a bound variable?
A) The page shows a warning
B) Compilation fails
C) The page does not display the value
D) The page renders with default value
Answer: C
Explanation: Without a getter method, the variable cannot be accessed and won’t display on the page.
30. What’s the effect of using “transient” keyword in a Visualforce controller variable?
A) The variable is saved to the database
B) The variable is serialized between requests
C) The variable is not saved in view state
D) The variable cannot be used in Visualforce
Answer: C
Explanation: transient
variables are excluded from the view state, reducing page size and improving performance.
31. What is the result of not including a setter method for a Visualforce input field bound to a controller variable?
A) The field becomes read-only
B) The value will not be updated in the controller
C) The page fails to compile
D) The field uses a default setter
Answer: B
Explanation: Without a setter, the controller cannot update the value of the variable from the input field.
32. Which method is called automatically when a Visualforce page is loaded with a custom controller?
A) render()
B) onPageLoad()
C) constructor
D) init()
Answer: C
Explanation: Apex class constructors are executed when the Visualforce page is loaded, initializing the controller.
33. What is the main benefit of using a StandardSetController
over a list of records in a custom controller?
A) It handles Apex triggers automatically
B) It manages DML operations
C) It provides built-in pagination and record selection
D) It ignores governor limits
Answer: C
Explanation: StandardSetController
provides built-in support for pagination and record selection from lists.
34. How can you prevent a user from accessing sensitive fields in a custom controller?
A) Using with sharing
B) By declaring variables private
C) By checking isAccessible()
on fields
D) Hiding the fields on the UI
Answer: C
Explanation: Field-Level Security (FLS) must be manually enforced in Apex using Schema.DescribeFieldResult.isAccessible()
.
35. What is the outcome if a method in a controller marked @RemoteAction
is not static
?
A) The method will fail to compile
B) The method will execute but return null
C) The method will execute in user context
D) The method cannot be accessed via JavaScript
Answer: D
Explanation: @RemoteAction
methods must be static
to be called from JavaScript in Visualforce pages.
36. Which of the following cannot be used directly inside a Visualforce page?
A) Apex class methods
B) Apex controller constructors
C) Apex triggers
D) Apex variables
Answer: C
Explanation: Apex triggers cannot be referenced directly in a Visualforce page.
37. How does @isTest(seeAllData=true)
impact test execution?
A) It ensures faster test execution
B) It allows test methods to access live organization data
C) It creates dummy test data
D) It disables governor limits
Answer: B
Explanation: seeAllData=true
allows access to actual org data, which is generally discouraged for reliable tests.
38. What is the default behavior of CRUD and FLS in custom controllers?
A) Automatically enforced
B) Enforced only for custom objects
C) Must be manually enforced
D) Enforced only on insert
Answer: C
Explanation: In custom controllers, developers are responsible for manually checking and enforcing CRUD/FLS rules.
39. What is returned by ApexPages.currentPage().getParameters().get('id')
?
A) The object’s name
B) A reference to the object
C) The record ID from the URL
D) The object schema
Answer: C
Explanation: This returns the id
parameter passed in the URL, typically for fetching the record.
40. What happens when you call save()
on a standard controller?
A) Saves a single record
B) Saves a list of records
C) Executes batch jobs
D) Only compiles the page
Answer: A
Explanation: save()
is a method on the standard controller that saves the record it is managing.
41. How can you implement sorting in a Visualforce page list?
A) Use JavaScript sorting
B) Use a SOQL ORDER BY
clause
C) Use ApexPages.sortList()
D) Use @OrderEnabled
Answer: B
Explanation: Sorting can be handled in the controller logic using SOQL with ORDER BY
.
42. Which keyword ensures a controller adheres to user-specific sharing rules?
A) public sharing
B) with sharing
C) user sharing
D) custom sharing
Answer: B
Explanation: with sharing
enforces the user’s record-level sharing rules during controller execution.
43. What does <apex:form>
do in a Visualforce page?
A) Defines a JavaScript form
B) Defines an HTML form
C) Allows input fields to submit to the controller
D) Encrypts data
Answer: C
Explanation: <apex:form>
allows input fields to post data back to the controller for processing.
44. What will cause a View State
size limit error in a Visualforce page?
A) Large SOQL query
B) Using too many Apex methods
C) Storing large collections in controller variables
D) Too many JavaScript functions
Answer: C
Explanation: Large data structures stored in controller variables can cause View State size limit errors.
45. What is the use of transient
keyword in Apex controllers?
A) Enables access to private data
B) Caches data between requests
C) Prevents the variable from being serialized in the view state
D) Enforces security
Answer: C
Explanation: transient
variables are excluded from the view state, reducing page size and improving performance.
46. Which Apex class provides methods to redirect users in Visualforce?
A) RedirectEngine
B) ApexRedirect
C) PageReference
D) VisualforceController
Answer: C
Explanation: PageReference
class provides the ability to redirect users programmatically.
47. Which Visualforce tag helps conditionally display content?
A) <apex:case>
B) <apex:renderIf>
C) <apex:outputPanel rendered="...">
D) <apex:conditional>
Answer: C
Explanation: The rendered
attribute on Visualforce components like <apex:outputPanel>
is used to show/hide content conditionally.
48. Which exception is thrown if a query returns more than one result but only one is expected?
A) TooManyRowsException
B) QueryException
C) RowLimitException
D) ListException
Answer: B
Explanation: A QueryException
is thrown when a SOQL query returns more than one result where only one is expected.
49. What is a benefit of using StandardController
in Visualforce pages?
A) It provides automatic DML methods
B) It avoids the need for Apex code
C) It simplifies test methods
D) It supports JavaScript libraries
Answer: A
Explanation: StandardController
provides built-in methods like save()
, edit()
, and delete()
.
50. How is the @future
annotation relevant to controller classes?
A) It is used for page rendering
B) It allows asynchronous processing
C) It improves page loading speed
D) It is required for @RemoteAction
methods
Answer: B
Explanation: @future
methods run asynchronously, which is helpful when performing callouts or time-consuming tasks.
51. Which Visualforce tag is required to include user input elements?
A) <apex:form>
B) <apex:commandLink>
C) <apex:outputField>
D) <apex:pageBlock>
Answer: A
Explanation: Input elements must be enclosed in <apex:form>
to allow submission to the controller.
52. What causes a Mixed DML Operation error in Apex?
A) Running more than 100 DML statements
B) Mixing DML on setup and non-setup objects in the same context
C) Using static variables
D) Calling test methods
Answer: B
Explanation: Salesforce restricts DML on setup (e.g., User) and non-setup (e.g., Account) objects in the same transaction.
53. What is the proper way to avoid SOQL injection in custom controllers?
A) Use dynamic SOQL
B) Use static variables
C) Use binding variables in SOQL
D) Escape input with JavaScript
Answer: C
Explanation: Binding variables in SOQL ensures that user input is treated safely, preventing injection attacks.
54. Which method refreshes a Visualforce page after DML operations?
A) controller.save()
B) PageReference.setPage()
C) return Page.pageName
D) Page.refresh()
Answer: C
Explanation: Returning a PageReference
refreshes or navigates to another page after DML execution.
55. What feature allows you to select multiple records in a Visualforce list?
A) <apex:repeat>
with checkboxes
B) StandardSetController
with selected
property
C) JavaScript loop
D) <apex:listSelect>
Answer: B
Explanation: StandardSetController
allows selection of records using its getSelected()
method.
56. Which tag automatically handles errors in Visualforce pages?
A) <apex:catch>
B) <apex:messages>
C) <apex:alert>
D) <apex:warn>
Answer: B
Explanation: <apex:messages>
displays all validation and processing errors to the user.
57. What does ApexPages.Message
do in a controller?
A) Logs errors
B) Sends alerts
C) Shows user messages on the Visualforce page
D) Submits forms
Answer: C
Explanation: ApexPages.Message
allows developers to display informational, warning, or error messages on the page.
58. What type of Apex method is best used for background processing of controller logic?
A) @RemoteAction
B) @future
C) @testSetup
D) static method
Answer: B
Explanation: The @future
annotation is used for asynchronous, background processing in Apex.
59. How can a controller communicate a success message to the Visualforce page?
A) Throw an exception
B) Use ApexPages.addMessage()
C) Use System.debug()
D) Return a Boolean
Answer: B
Explanation: ApexPages.addMessage()
is used to show success or error messages to users on Visualforce pages.
60. What is the main function of <apex:commandButton>
?
A) Submits a form to the server
B) Refreshes the Visualforce page
C) Runs JavaScript
D) Shows a popup
Answer: A
Explanation: <apex:commandButton>
submits the form to the controller and triggers associated action methods.
Sample Set 2
1. What happens when a Visualforce page uses a standard controller but no record ID is passed in the URL?
A) The page throws an exception
B) The page renders with an empty record instance
C) The page automatically redirects to a record selection page
D) The page uses a default record of the first object instance
Answer: A
Explanation: Standard controllers require a record ID; otherwise, they throw an exception because they can’t load the record.
2. In Apex, what is the difference between with sharing
and without sharing
keywords, and when would you use each?
A) with sharing
enforces sharing rules, use for user-level data access; without sharing
ignores sharing, used for system-level operations
B) Both behave the same
C) with sharing
disables sharing rules, without sharing
enforces sharing
D) Used only for test classes
Answer: A
Explanation: Use with sharing
for respecting org sharing, and without sharing
when you need system-level access.
3. Explain how Visualforce View State impacts page performance and how to reduce it.
A) View State stores page and controller data between requests; large View State slows down performance. Reduce by minimizing component usage, using transient variables, and avoiding large collections in controllers.
B) View State is stored server-side only; no effect on performance
C) View State only stores static resources
D) View State is irrelevant for Visualforce pages
Answer: A
Explanation: Optimizing View State improves page load speed and reduces heap size.
4. What governor limits apply to synchronous Apex versus asynchronous Apex? Provide at least two differences.
Answer:
Synchronous Apex: 100 SOQL queries, 150 DML statements, 6 MB heap size
Asynchronous Apex (Batch, Queueable): Higher limits, e.g., 200 SOQL queries, 12 MB heap size
Explanation: Asynchronous Apex allows higher limits because processes run independently.
5. How do you implement pagination on a Visualforce page that displays a large dataset?
A) Use StandardSetController
with its next()
, previous()
, and getRecords()
methods
B) Use LIMIT
in SOQL only
C) Use batch Apex
D) Pagination is not possible in Visualforce
Answer: A
Explanation: StandardSetController
simplifies pagination and record selection.
6. Describe the difference between a Custom Controller and a Controller Extension in Visualforce.
Answer:
Custom Controller: Apex class that replaces the entire controller logic.
Controller Extension: Apex class that extends the standard or custom controller, adding or overriding functionality without replacing the existing controller.
7. Why should you avoid performing SOQL queries or DML operations inside loops in Apex? What is the best practice?
Answer: Performing queries/DML inside loops can quickly hit governor limits, causing runtime exceptions. Best practice is bulkifying code by moving queries/DML outside loops, processing collections of records.
8. How can you handle exceptions gracefully in Apex controllers used by Visualforce pages?
A) Use try-catch blocks in Apex methods and display user-friendly messages with <apex:pageMessages>
B) Do not catch exceptions
C) Throw exceptions to the user directly
D) Use System.debug()
only
Answer: A
Explanation: Try-catch allows controlled error handling and displaying meaningful messages.
9. What is the purpose of the @RemoteAction
annotation in Apex? How does it work with Visualforce?
Answer: It exposes static Apex methods to JavaScript remoting, allowing Visualforce pages to call Apex asynchronously from JavaScript without full page reloads.
10. In what scenarios would you use @future
methods in Apex? What are their limitations?
Answer: Use @future
for asynchronous processing like callouts or long-running operations. Limitations include no guaranteed order of execution, no return values, and inability to call from another @future
method.
11. How can you enforce CRUD and FLS (Field-Level Security) in Apex controllers used in Visualforce?
A) Use Schema.sObjectType
methods to check permissions before querying or updating records
B) Assume all permissions granted
C) Use with sharing
only
D) Security is handled automatically
Answer: A
Explanation: Apex does not enforce FLS/CRUD automatically; explicit checks are needed.
12. How does the Database.SaveResult
class help when performing DML operations?
Answer: It provides detailed success/failure info for each record processed in bulk DML, enabling error handling and reporting at the record level.
13. What are the differences between System.schedule()
and Database.executeBatch()
?
Answer:
System.schedule()
schedules Apex classes implementingSchedulable
to run at specific times.Database.executeBatch()
runs batch Apex jobs immediately or asynchronously for processing large datasets.
14. How do you write a test method that ensures 100% coverage for a Visualforce controller?
Answer: Write test methods that instantiate the controller, simulate page parameters if needed, call all controller methods, and assert expected results.
15. Explain how you can pass data between Visualforce pages and Apex controllers using URL parameters and controller properties.
Answer: Use page URL parameters accessed via ApexPages.currentPage().getParameters()
, and bind Visualforce input components to controller properties with getters/setters.
16. What is the effect of using transient
keyword on a controller variable in Visualforce?
Answer: It excludes the variable from View State, reducing View State size, but the variable is not persisted between requests.
17. Describe the role of the ActionRegion
component in Visualforce.
Answer: It limits which components’ data are processed during an AJAX request, improving performance by sending only parts of the form to the server.
18. How can you debug issues related to governor limits in Apex?
Answer: Use debug logs with Limits.get...
methods to monitor resource usage, and analyze logs in Developer Console or Setup to identify limit breaches.
19. Describe how custom metadata types can be leveraged in Apex controllers.
Answer: Custom metadata allows storing configuration data that can be accessed in Apex without SOQL queries, improving performance and easier maintenance.
20. What is the maximum heap size allowed in synchronous Apex? How can you avoid exceeding it?
Answer: 6 MB in synchronous Apex. Avoid by processing data in smaller chunks, using efficient data structures, and minimizing large collections.
21. How do you ensure a Visualforce page is secure against SOQL injection attacks?
Answer: Use bind variables in SOQL queries rather than concatenating strings from user input.
22. When would you use @TestSetup
methods in Apex test classes?
Answer: To create common test data once per test class, reducing redundant code and improving test performance.
23. Explain the difference between Queueable
Apex and Future
methods.
Answer:
Queueable allows chaining jobs, supports complex types, and has better job monitoring.
Future methods are simpler but limited (no chaining, primitive parameters only).
24. How can you invoke Apex REST endpoints from Visualforce pages?
Answer: Use JavaScript XMLHttpRequest
or fetch()
to call REST endpoints exposed by Apex classes annotated with @RestResource
.
25. What considerations should you make when designing Apex triggers to ensure controller performance isn’t degraded?
Answer: Minimize triggers’ complexity, avoid recursive calls, bulkify operations, and handle exceptions properly.
26. How does Salesforce handle session state for Visualforce pages, and what are implications for controller design?
Answer: Controller instances are serialized in View State; excessive state data increases page load times and may cause limits to be exceeded.
27. How do you make a Visualforce page cacheable to improve performance?
Answer: Use cache="true"
in <apex:page>
tag and ensure the page content is not dynamic or user-specific.
28. What is the difference between apex:inputField
and apex:inputText
?
Answer:
inputField
binds directly to a Salesforce field and respects field-level security and data types.inputText
is a generic input box not tied to a field.
29. How do you avoid recursion in Apex triggers?
Answer: Use static Boolean flags or custom helper classes to prevent a trigger from running multiple times during a single transaction.
30. What is the purpose of @TestVisible
annotation and when would you use it?
Answer: It exposes private variables or methods to test classes to facilitate unit testing without changing production code visibility.