Request More Information

Email:  WhatsApp:

koenig-logo

Programmatic Development Using Apex and Visualforce (DEX 450) Quiz Questions and Answers

Answer :
  • The model represents Salesforce data, the view is the Visualforce markup page, and the controller is the logic layer that prepares data and manages actions.

Explanation :

In Salesforce Visualforce, the MVC architecture separates concerns as follows: the model consists of Salesforce data (standard or custom objects), the view is the Visualforce page markup, and the controller is the logic (either standard or Apex) that interacts between the model and the view. Option A correctly describes this separation of concerns. Option B mixes up MVC roles, option C mislabels the controller and model, and option D incorrectly asserts that the controller and view are combined.
Answer :
  • Avoid placing SOQL queries inside getter methods.

Explanation :

Best practices for Apex custom controllers include avoiding SOQL queries in getter methods, as getters are called multiple times during the Visualforce page lifecycle. Placing expensive operations like SOQL in getters can quickly cause governor limit issues and degrade performance. Hardcoding record IDs, keeping all variables persistent (instead of marking some as 'transient'), and mixing business and UI logic in markup are all poor practices that should be avoided.
Answer :
  • It provides the logic layer that determines how data is processed and how user actions are handled.

Explanation :

In Salesforce's MVC (Model-View-Controller) architecture, the controller is responsible for the logic layer: it determines how data is processed, how user actions are managed, and connects UI actions to Apex logic. Option B correctly identifies this responsibility. Option A describes the view; option C refers to the model; option D refers to UI styling, not the controller logic.
Answer :
  • To add custom logic to a standard controller without rewriting CRUD operations.

Explanation :

A controller extension is used to enhance the functionality of a standard controller by adding custom logic, without having to reimplement standard CRUD operations provided by Salesforce. Option B is incorrect because that's the purpose of a custom controller, not an extension. Options C and D do not describe the role of a controller extension.
Answer :
  • Custom Controllers provide full control over page logic, data retrieval, and can handle requirements beyond standard operations.

Explanation :

Custom Controllers give the developer complete control over logic and data retrieval, enabling support for advanced and custom behaviors that go beyond the default operations of Standard Controllers. They do NOT automatically bypass security checks; in fact, CRUD and FLS checks must be enforced manually.
Answer :
  • Use 'with sharing' keyword and perform explicit CRUD and FLS checks in Apex code.

Explanation :

While the 'with sharing' keyword enforces record-level sharing, custom controllers must explicitly check for object-level (CRUD) and field-level security (FLS) in Apex to avoid exposing data. Standard Controllers handle this automatically, but custom logic demands checks in code.
Answer :
  • SOQL queries in getters can result in exceeding governor limits since getters may run multiple times per request.

Explanation :

Because getter methods are invoked multiple times during rendering, placing SOQL queries inside them can cause multiple, redundant queries to execute on a single page view, risking governor limit violations. Queries should instead be placed in constructors or designated methods.
Answer :
  • Built-in support for searching, sorting, and pagination of record lists

Explanation :

Standard List Controllers offer built-in capabilities such as searching, sorting, and pagination, saving the developer from implementing these features manually for record lists. The other options are either not relevant or not provided by Standard List Controller by default.
Answer :
  • When combining data from multiple objects and requiring complex logic or custom UI behavior.

Explanation :

Custom Controllers are ideal when you need to implement advanced business logic, combine data from multiple objects, or build fully customized UIs. Standard Controllers are sufficient for basic CRUD. Sharing rules can be enforced in any controller type if specified.
Answer :
  • They automatically enforce Salesforce's security model, including CRUD and FLS.

Explanation :

Standard Controllers in Visualforce provide basic operations on both standard and custom objects and automatically respect object and field-level security. No custom Apex is needed for basic use, and validation rules are enforced automatically. Option B is correct.