User Interface Ob1 Flashcards

1
Q

A developer needs to retrieve certain records and load them in a table on a Visualforce page. The developer would like to be able to customize the look and feel of the table and not use standard Salesforce styling.

What Visualforce components can the developer use?

A. <apex:dataList>, <apex:listTable>, or <apex:table>
B. <apex:dataTable>, <apex:dataList>, or <apex:repeat>
C. <apex:pageBlockTable>, <apex:dataTable>, or <apex:dataList>
D. <apex:table>, <apex:listTable>, or <apex:pageBlockTable>

A

B. <apex:dataTable>, <apex:dataList>, or <apex:repeat>
The <apex:dataTable>, <apex:dataList>, and <apex:repeat> Visualforce components can be used to create tables with custom styles.
The <apex:pageBlockTable> component can be used to build a table but comes with default Salesforce styling. A Visualforce component called <apex:table> or <apex:listTable> does not exist.

apex:dataTable

apex:dataList

Display Records, Fields, and Tables

🧠 Explanation:
If a developer wants full control over styling (i.e. not use standard Salesforce CSS or styling), the best components to use are:

<apex:dataTable> – renders a table and allows full CSS styling.

<apex:dataList> – similar to a data table but rendered as an HTML list.

<apex:repeat> – extremely flexible, lets you repeat any markup (including divs, tables, etc.) and apply custom styles freely.

❌ Why the other options are wrong:
A and D: <apex:listTable>, <apex:table> are not valid Visualforce components.

C: <apex:pageBlockTable> uses standard Salesforce styling, which goes against the requirement.
</apex:pageBlockTable></apex:table></apex:listTable></apex:repeat></apex:dataList></apex:dataTable>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The sales representatives of Cosmic Lights use a Visualforce page in Salesforce to search for and view billing information related to account records. A custom object named Billing__c is used for this.

The page currently uses a standard controller.

Now, the company wants sales reps to click a button on that page to:

Retrieve billing info from an external system via REST callout, and

Update the Salesforce record accordingly.

A. Use a custom controller in order to perform all the required operations and execute REST-based callouts to the external system.

B. Edit the standard controller of the Visualforce page and add the code to execute a REST-based callout to the external system.

C. Replace the standard controller with a controller extension to perform all required operations and REST-based callouts to the external system.

D. Use the standard callout action of the standard controller in order to execute a REST-based callout to the external system.

A

✅ Correct Answer: A.

🧠 Explanation:
Standard controllers in Visualforce are great for basic CRUD operations. However:

They cannot execute REST callouts.

They cannot include custom logic like calling external APIs.

To perform a REST-based callout and update Salesforce data, the developer must:

Create a custom controller class.

Define a method that performs the callout.

Add logic to update the Billing__c record with the response.

➡️ This gives full control over the backend behavior.

What are Custom Controllers and Controller Extensions?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

A developer is building an Apex controller for a Visualforce page and wants to ensure that the heap size is minimized to avoid performance issues.

Which of the following practices can help keep the heap size low?

A. Use Limit methods to extend the governor limits on memory usage.
B. Use a SOQL for loop for processing results returned by a query.
C. Use the ‘transient’ keyword with variables when declaring them.
D. Store all results of a SOQL query in a variable first before iterating.

A

B. Use a SOQL for loop for processing results returned by a query.
C. Use the ‘transient’ keyword with variables when declaring them.

Using the ‘transient’ keyword prevents an instance variable from being transmitted as part of the view state of a Visualforce page. SOQL for-loops use efficient chunking to reduce the heap size. Saving all results of a SOQL query in a variable at once causes all data to be placed in memory instead of it being retrieved in chunks as needed. Limit methods are used to monitor/manage the heap during execution and not to reduce the total amount of memory used. For example, Limits.getLimitHeapSize() returns the total amount of memory (in bytes) that can be used for the heap in the current context.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

If a developer is required to create a page that allows performing standard actions on multiple records, what controller can accomplish this with the least effort?

A. Custom Controller
B. Standard List Controller
C. Standard Controller
D. Lightning Bundle Controller

A

B. Standard List Controller

🧠 Explanation:
The Standard List Controller is specifically designed to handle multiple records of a given object in Visualforce pages. It comes prebuilt with standard functionality like:

  • View
  • Edit
  • Delete
  • Pagination
  • Sorting

All this without having to write custom Apex code. That makes it the most efficient choice when your goal is to act on a list of records with minimal development effort.

Associating a Standard List Controller with a Visualforce Page

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What attribute should the developer use to render a Visualforce page as a PDF file?

A. renderAs=”pdf”
B. docType=”pdf-5.0”
C. contentType=”application/vnd.pdf”
D. docType=”pdf-1.0-strict”

A

✅ Correct Answer: A.

A developer can generate a downloadable, printable PDF file of a Visualforce page using the PDF rendering service. A Visualforce page rendered as a PDF file displays either in the browser or is downloaded, depending on the browser’s settings. Specific behavior depends on the browser, version, and user settings, and is outside the control of Visualforce.

Render a Visualforce Page as a PDF File

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which iteration components can be used to display a table of data on a Visualforce page?

A. <apex:outputTable> and <apex:pageBlockTable>
B. <apex:table> and <apex:outputTable>
C. <apex:dataTable> and <apex:table>
D. <apex:pageBlockTable> and <apex:dataTable>

A

D. <apex:pageBlockTable> and <apex:dataTable>

Iteration components work on a collection of items instead of a single value. <apex:pageBlockTable> is a type of iteration component that can be used to generate a table of data, complete with platform styling. The <apex:dataTable> component can be used if custom styling is required.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

A developer is required to build a Visualforce page that allows a user to upload an attachment for a record. In the upload form, Attachment fields such as Name and Description must be populated by the user, as well as certain additional fields that will be saved to the parent record.

A. Standard List Controller
B. Custom Controller
C. Standard Controller
D. Custom List Controller

A

B. Custom Controller

🧠 Explanation:
To build a Visualforce page that:

Allows uploading attachments,

Populates fields like Name and Description,

AND updates additional fields on the parent record,

…the developer needs full control over the form logic, file handling, and saving process. That level of customization requires a Custom Controller.

With a Custom Controller, you can:

Manually manage the file upload using Attachment.Body or ContentVersion.VersionData

Set all fields programmatically

Handle saving the parent record and the attachment in one transaction

What are Custom Controllers and Controller Extensions?

Create & Use Custom Controllers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Using the sample controller class below, what is the value of the count variable when the following line is run?

MyController c = new MyController();
Integer x = c.count;

Code:

public class MyController {
    public Integer count {
        get {
            if (count == null) {
                System.debug('get count');
                count = 10;
            } else {
                System.debug('increment count');
                count++;
            }
            return count;
        }
        private set;
    }

    public MyController() {
        System.debug('constructor begins');
        if (count == null) {
            count = 20;
        }
        System.debug('constructor ends');
    }

    public void logCount() {
        System.debug('The value of count is: ' + count);
    }
}

A. 10
B. 21
C. 11
D. 20

A

C. 11

In the constructor, when the “if statement” reads the count variable, the get property of the variable is called before the conditional block starts the evaluation. In the get property, count will have been null so its value will be set to 10 and returned.

The value is then received back into the “if statement”, and since count has been set to 10 at this point, it will not satisfy the condition during the evaluation. When the count variable is referenced in the logCount method, the get property is called again, but this time the value will be incremented since it no longer contains a null value.

Build a Custom Controller

Apex Properties

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

A developer is creating a customized page in which the standard record detail page of an object is included.

A. <apex:detail>
B. <apex:dataList>
C. <apex:record>
D. <apex:recordPage></apex:recordPage></apex:record></apex:dataList></apex:detail>

A

✅ Correct Answer: A.

🧠 Explanation:
The <apex:detail> component is used when you want to display the standard Salesforce detail page layout for a record inside a Visualforce page.</apex:detail>

It’s the easiest way to embed the default layout (fields, sections, related lists) that a user would normally see when viewing a record.

<apex:page standardController="Account">
    <apex:detail relatedList="true" title="true"/>
</apex:page>

This displays:

The record detail section
The related lists (if relatedList=”true”)
The standard page title (if title=”true”)

❌ Why the others are incorrect:
B. <apex:dataList> → Used to display a list of records, not a detail page.</apex:dataList>

C. <apex:record> → ❌ No such component in Visualforce.</apex:record>

D. <apex:recordPage> → ❌ Not a valid Visualforce tag.</apex:recordPage>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

A developer is creating a custom controller which will contain a web service method.
Which access modifier must be used to declare the class?

A. public
B. private
C. global
D. protected

A

C. global
🧠 Explanation:
En Apex, si vas a definir un método con la palabra clave webService, necesitas que la clase también sea accesible desde fuera del sistema Salesforce, como desde una integración externa.

Para eso, se necesita que la clase sea global.

📌 Esto es lo que debes tener en cuenta:

webService methods deben estar en una clase con el modificador global.

public no es suficiente si el método será usado desde fuera de Salesforce.

Apex classes containing web service methods must be defined as global, which will allow the class to be used anywhere in the org, including Apex code that belongs to other packages.

The private access modifier cannot be used on top-level classes. The public access modifier makes a class accessible to Apex code within the same package. The protected access modifier can only be used on class methods.

Considerations for Creating Custom Controllers and Controller Extensions

Considerations for Using the webservice Keyword

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

A developer at Cosmic Solutions needs to create a Visualforce page to display Case records in a table and is considering to use a standard list controller so that building a custom controller is not necessary.

Which of the following is a valid consideration when using standard list controllers?

A. A dynamic number of records can be loaded on the page
B. Records can be dynamically sorted by rendered fields
C. A controller extension must be used for record pagination
D. Existing list view filters cannot be applied to the records

A

✅ Correct Answer: A.

🧠 Explanation:
The Standard List Controller in Visualforce is used to work with a collection of records (e.g., a list of Cases). It provides built-in support for:

Pagination

Sorting (based on list views)

Filtering via standard list view filters

Loading a configurable number of records per page (like 10, 25, 50, etc.)

📌 So A is correct because you can control how many records to display by using standard pagination features like:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

A developer is required to create a Visualforce page that displays data from a web service callout.
Which of the following options, on its own, can meet this requirement?

Choose 1 answer.

A. Controller Extension
B. Custom Controller
C. Standard List Controller
D. Standard Controller

A

B. Custom Controller

🧠 Explanation:
Cuando quieres hacer un web service callout (como llamar a una API externa desde Apex), necesitas tener acceso total a la lógica Apex para:

Definir el método que hace el callout (Http, HttpRequest, etc.)

Manejar los datos que vienen de la respuesta

Controlar cómo se muestran en la página

👉 Esto no se puede hacer con un Standard Controller ni con un Standard List Controller, ya que esos no permiten lógica personalizada como callouts.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

A Salesforce developer needs to execute custom logic on records that users select in a related list.
Which method of the StandardSetController class can be used to return the records selected by a user?

Choose 1 answer.

A. getChecked()
B. getCheckedList()
C. getSelected()
D. getSelection()

A

C. getSelected()

The getSelected() method returns a list of sObjects representing the selected records.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

A developer has a requirement to display a chart on the Account page layout to help users visualize data.
Which of the following statements is true about using charts on a Visualforce page?

A. Visualforce charts can be displayed in a Visualforce page rendered as PDF
B. Third-party JavaScript charting libraries are not supported on a Visualforce page
C. Visualforce charts can be used for visualizing report data in Report Builder
D. A collection of standard components can be used to create Visualforce charts

A

✅ Correct Answer: D.
A collection of standard components can be used to create Visualforce charts``

🧠 Explanation:
Salesforce ofrece una serie de componentes estándar de Visualforce como:

<apex:chart>

<apex:pieSeries>

<apex:barSeries>

<apex:lineSeries>

Estos componentes permiten crear gráficos directamente en Visualforce, sin necesidad de JavaScript adicional.

Con ellos puedes visualizar datos de objetos de Salesforce fácilmente. Se basan en el framework gráfico Flash Charting (aunque es limitado y antiguo), pero funcionan para necesidades básicas.
</apex:lineSeries></apex:barSeries></apex:pieSeries></apex:chart>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Which of the following methods can be annotated with @future in custom controllers?

A. Setter methods
B. Web service callouts
C. Constructor methods
D. Getter methods

A

B. Web service callouts

Methods that perform DML statements or web service callouts can use the @future annotation.

Getter, setter, and constructor methods in custom controllers can’t be annotated with @future since the processing of a page depends on these methods immediately returning or processing data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

When initializing a StandardSetController, which of the following data types is a valid argument that can be passed to its constructor?

A. List<sObject> or Database.QueryLocator
B. Database.QueryLocator or Set<sObject>
C. Map<Id, sObject> or List<sObject>
D. Set<sObject> or Map<Id, sObject>

A

A. List<sObject> or Database.QueryLocator

A StandardSetController can be instantiated using either a list (List<sObject>) or a query locator (Database.QueryLocator). Using other data types will throw an error during compile time.</sObject>

Note that if a query locator that returns more than 10,000 records is used to initialize a StandardSetController, a LimitException will be thrown. On the other hand, if a list with more than 10,000 records is used, the list will be automatically truncated to the maximum allowed number of records (10,000), and no exception will be thrown.

StandardSetController Class

StandardSetController Constructors

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

A developer needs to display a map that shows locations of properties sold by a real estate agent. How can this requirement be achieved using Visualforce?

A. Generate the map using the <apex:map> component
B. Use the Salesforce JavaScript library for creating maps
C. Activate the map mode in Visualforce charts
D. Add the <apex:google> component to generate the map

A

A. Generate the map using the <apex:map> component

Salesforce provides the <apex:map> component to support and display interactive maps on Visualforce pages. The map is capable of displaying multiple markers and comes with viewing controls for zooming and panning. Please note, however, that Visualforce mapping components are not available in Developer Edition orgs.

Salesforce does not provide a JavaScript library to its users for creating maps. There is no <apex:google> component, and Visualforce charts do not have a map mode.

apex:map

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

A developer is building a calculator application using a Visualforce page that will have two numerical input fields and perform an arithmetic operation based on the user input. What method should the developer use in order to accept and pass the input of the user to the controller?

A. Setter Method
B. Pass Method
C. Input Method
D. Accept Method

A

A. Setter Method

Setter Method – The [set] method is used to pass values from the Visualforce page to the controller. Setter methods pass user-specified values from page markup to a controller. Any setter methods in a controller are automatically executed before any action methods.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

A developer has created a list of 11,000 records. What will happen if the developer instantiates a standard set controller using this list?

Choose 1 answer.

A. An exception will be thrown
B. The set will be instantiated without any issues
C. The set will be instantiated but the record list will be truncated
D. The set will be instantiated but paging functionality will be unstable

A

C. The set will be instantiated but the record list will be truncated

Instantiating a StandardSetController with a list of more than 10,000 records doesn’t throw an exception. Instead, the record list is truncated to the allowable limit. On the other hand, instantiating StandardSetController using a query locator returning more than 10,000 records causes a LimitException to be thrown.

🧠 Explanation:
When you use a StandardSetController in Apex, it supports up to 10,000 records.

If you instantiate it using a Database.QueryLocator and the query returns more than 10,000 records, an exception will be thrown.

BUT if you instantiate it using a List<sObject> (like in this case), no exception is thrown, but the list is truncated to the first 10,000 records.</sObject>

In this scenario, the developer is instantiating the controller using a list with 11,000 records, so the system will simply cut off (truncate) the list to 10,000 records.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Which of the following statements is true about displaying data on a Visualforce page?

Choose 1 answer.

A. JavaScript is required in order to bind components to data available via the controller.
B. Object data, but not global data, can be displayed on a Visualforce page.
C. The record to load on a page is identified via an id parameter included in the page URL.
D. The <apex:fieldValue> component can be used to display individual fields from a record.</apex:fieldValue>

A

C. The record to load on a page is identified via an id parameter included in the page URL.

To bind components to data available in the controller of a Visualforce page, the expression syntax is used such as {! Record.Name }. Both object (sObjects) and global (profiles, users, company, locale, etc.) data can be displayed on a Visualforce page using the expression syntax. The <apex:outputField> component can be used to display individual fields from a record. There is no component called <apex:fieldValue> in Visualforce.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

If LeadExtA, LeadExtB, and LeadExtC in the code snippet below represent the names of Visualforce controller extensions, which of the following statements is true?

<apex:page standardController="Lead" extensions="LeadExtA,LeadExtB,LeadExtC">
  <apex:outputText value="{!display}" />
</apex:page>

A. The Visualforce page will only use LeadExtA as long as no errors are encountered when loading.
B. LeadExtA, LeadExtB, or LeadExtC can be used without specifying the Lead standard controller.
C. If the same method exists in all extensions, the LeadExtC method overrides all the other methods.
D. LeadExtA, LeadExtB, and LeadExtC are controller extensions used by the Visualforce page.

A

D. LeadExtA, LeadExtB, and LeadExtC are controller extensions used by the Visualforce page.

Multiple controller extensions can be defined for a single page through a comma-separated list. Overrides are defined by whichever methods are defined in the leftmost extension. Meaning, if the same method exists in all the controller extensions in this scenario, the method from LeadExtA will override the method that is defined in LeadExtB and LeadExtC.

Extensions are required to extend either a standard controller or a custom controller. In this scenario, the Lead standard controller would be required. Extensions can be reused on different Visualforce pages. Developers should plan ahead and use inheritance either from a superclass or an interface to avoid too many constructors.=

Building a Controller Extension

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Which of the statements is true regarding a StandardSetController?

Choose 1 answer.

A. It can be used to generate custom reports in Report Builder.
B. It can be used to perform bulk updates without writing code.
C. It can be used to perform or extend list controller functionality.
D. It can be used to process more than 10,000 records at a time.

A

C. It can be used to perform or extend list controller functionality.

The StandardSetController is an Apex class that can be used to perform or extend the functionality available in standard Visualforce page list controllers. Using the StandardSetController requires writing Apex code and is typically used in Visualforce pages that perform, for example, mass updates on records.

The maximum record limit for StandardSetController is 10,000 records. If a query locator is used for instantiating the StandardSetController to return more than 10,000 records, then a LimitException will be thrown. However, instantiating StandardSetController with a list of more than 10,000 records will not throw an exception, and instead trims the records down to the limit. Apex cannot be used to create reports in Report Builder.

StandardSetController Class

StandardSetController Methods

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

A developer at Cosmic Solutions has uploaded a zip file called ‘StyleResource’ to a Salesforce org. The static resource contains a CSS file named ‘cosmic.css’. How can this CSS file be referenced in a Visualforce page that the developer is working on?

👇 Choose 1 answer:

A. <apex:include value="{!URLFOR($Resource.StyleResource, 'cosmic.css')}"/>
B. <apex:style value="{!URLFOR($Resource.StyleResource, 'cosmic.css')}"/>
C. <apex:stylesheet value="{!URLFOR($Resource.StyleResource, 'cosmic.css')}"/>
D. <apex:includeScript value="{!URLFOR($Resource.StyleResource, 'cosmic.css')}"/>

A

C. <apex:stylesheet value="{!URLFOR($Resource.StyleResource, 'cosmic.css')}"/>

A CSS stylesheet can be referenced in Visualforce pages by using the component <apex:stylesheet/>. The attribute ‘value’ of this component uses the URL to the CSS file or a reference to a static resource via the function URLFOR.

<apex:style/> is not a valid component in Visualforce. <apex:includeScript/> is used in referencing JavaScript files, and <apex:include/> allows another Visualforce page to be referenced in the current one.

apex:stylesheet

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Which step is valid for retrieving ‘First Priority’ case records in a custom Visualforce controller using a StandardSetController?

A. Accept StandardSetController in the controller constructor
B. Instantiate StandardSetController with a list or query locator
C. Use <apex:pageBlockTable> with value set to {!getPriorityCases}
D. Set standardSetController=”FirstPriorityCaseController” on <apex:page>

A

✅ B. Instantiate StandardSetController with a list or query locator

This is the correct way to use StandardSetController inside a custom controller. It enables pagination and efficient handling of filtered records like ‘First Priority’ cases.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Cosmic Solutions is creating a Visualforce page to render the 'First Priority' case records of the current user. The company defines these records as cases whose priority is set to High and status is set to New, and have a skill rating that matches the current user's skill rating. Skill rating is identified by corresponding custom fields on the Case object and the User object. A Visualforce page controller called 'FirstPriorityCaseController' needs to be created to include a 'getPriorityCases' method, which uses a Standard Set Controller to retrieve the cases. Which of the following represents a valid step in meeting the requirement? Choose 1 answer. A. Define the standardSetController='FirstPriorityCaseController' attribute on . B. Add an with its 'value' attribute set to {!getPriorityCases}. C. Instantiate an ApexPages.StandardSetController with an sObject list or query locator. D. Accept an ApexPages.StandardSetController in the constructor of the page controller.
C. Instantiate an ApexPages.StandardSetController with an sObject list or query locator. 🧠 Explanation: An instance of ApexPages.StandardSetController can be defined using an sObject list that contains the case records or a Database.getQueryLocator() that returns the records. The ApexPages.StandardSetController class has a getRecords() method which returns a subset of records that can depend on certain factors such as pagination and page size. The getRecords() method can be called from the getPriorityCases() method of the custom controller. To access getPriorityCases() using` `, for example, the property is specified in its "value" attribute without the "get" prefix such as "value={!priorityCases}". The FirstPriorityCaseController class should be specified using the "controller" attribute on . A "standardSetController" attribute for does not exist. Unlike controller extensions, which can accept an ApexPages.StandardController argument when extending a standard controller, custom controllers such as the FirstPriorityCaseController class in this scenario cannot accept arguments in their constructors. 🔗 Official Documentation: - [StandardSetController Class](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_pages_standardsetcontroller.htm) - [Controllers and Controller Extensions](https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_std_set_controller.htm) 📚 Additional Resources: - [Use Standard List Controllers in Visualforce Pages - Trailhead](https://trailhead.salesforce.com/content/learn/modules/visualforce_fundamentals/visualforce_standard_list_controllers) - [StandardSetController Example - Salesforce Help](https://help.salesforce.com/s/articleView?id=000384158&type=1)
26
What is true regarding the view state in a Visualforce page? Choose 1 answer. A. There is no limit to the size of the view state B. The view state is used to store state across multiple user sessions C. The view state is used to store state across multiple pages such as in a wizard D. The view state is used to store the layout of a Visualforce page
✅ C. The view state is used to store state across multiple pages such as in a wizard 🧠 Explanation: The view state in Visualforce is used to persist state (e.g., field values, controller state, etc.) *within the same user session and across multiple requests to the same page*, which is common in wizards or multi-step flows. It is not meant for cross-session persistence. ❌ Why the other options are incorrect: A. False — The view state has a limit (typically 170 KB). Exceeding this can cause performance issues or errors. B. False — The view state is not persisted across sessions; it only lasts for the current page lifecycle and user session. D. False — The layout is defined in Visualforce markup (``, etc.), not in the view state. The view state stores state-related data (e.g., values of variables). 🔗 Official Documentation: - [Visualforce View State](https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_viewstate.htm) - [Optimizing View State](https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_best_practices.htm) 📚 Additional Resources: - [Visualforce View State Trailhead Module](https://trailhead.salesforce.com/content/learn/modules/visualforce_fundamentals/visualforce_data_view_state) - [Understanding View State in Visualforce - Salesforce Help](https://help.salesforce.com/s/articleView?id=000324607&type=1)
27
What is true regarding the view state in a Visualforce page? Choose 1 answer. A. There is no limit to the size of the view state B. The view state is used to store state across multiple user sessions C. The view state is used to store state across multiple pages such as in a wizard D. The view state is used to store the layout of a Visualforce page
✅ B. The view state is used to store state across multiple user sessions A 'set' method should be used to pass data from a Visualforce page to its Apex controller. To pass data from an Apex controller to a Visualforce page, a 'get' method must be used. The name of the getter method without the 'get' prefix should be used to display results from a getter method. Also, getter methods should be designed to produce the same outcome, whether they are called once or multiple times for a single page request. It is a best practice for getter methods to be idempotent, which means they should not have side effects. For example, they should not include logic that increments a variable, outputs a log message, or adds a new record to the database. Visualforce does not define the order in which getter methods are called, or how many times they might be called in the course of processing a request. Getter methods return values from a controller. Every value that is calculated by a controller and displayed on a page must have a corresponding getter method, including any Boolean variables. 🔗 Official Documentation: - [Visualforce View State](https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_viewstate.htm) - [Optimizing View State](https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_best_practices.htm) 📚 Additional Resources: - [Visualforce View State Trailhead Module](https://trailhead.salesforce.com/content/learn/modules/visualforce_fundamentals/visualforce_data_view_state) - [Understanding View State in Visualforce - Salesforce Help](https://help.salesforce.com/s/articleView?id=000324607&type=1)
28
What is a valid constructor for a custom controller named MyController for a Visualforce page? Choose 1 answer. A. public MyController(Contact contact) { currentContact = contact; } B. public MyControllerConstruct() { construct(); contact = new Contact(); } C. public Contact MyController() { contact = new Contact(); return contact; } D. public MyController() { contact = new Contact(); }
✅ D. public MyController() { contact = new Contact(); } 🧠 Explanation: In Apex, a valid constructor must have the same name as the class and must not return a value. Option D is the only one that correctly defines a constructor for the class `MyController`, which is commonly used as a custom controller in a Visualforce page. ❌ Why the other options are incorrect: A. While the syntax looks correct, it only makes sense if the Visualforce page passes a `Contact` parameter to the constructor — which is not typical behavior for Visualforce controllers. B. The constructor name must match the class name exactly. `MyControllerConstruct` is not valid for a class named `MyController`. C. This is invalid because constructors cannot have a return type. `public Contact MyController()` is interpreted as a method, not a constructor. 🔗 Official Documentation: - [Apex Classes - Constructors](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_constructors.htm) - [Custom Controllers in Visualforce](https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_custom.htm) 📚 Additional Resources: - [Visualforce & Apex Controllers - Trailhead](https://trailhead.salesforce.com/content/learn/modules/visualforce_fundamentals/visualforce_custom_controllers) - [Custom Controller Example - Salesforce Developers](https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_custom_example.htm)
29
Which of the following action methods are supported by standard controllers? Choose 1 answer. A. Edit, Delete, and Export B. Select, Edit, and List C. Save, Select, and Quicksave D. Quicksave, Delete, and Cancel
✅ D. Quicksave, Delete, and Cancel 🧠 Explanation: Standard controllers in Visualforce support a predefined set of action methods, which include: - `save()` - `quicksave()` - `delete()` - `cancel()` - `edit()` - `first()`, `last()`, `next()`, `previous()` — for pagination From the options listed, only **D** contains three valid methods (`quicksave`, `delete`, and `cancel`) that are officially supported by standard controllers. ❌ Why the other options are incorrect: A. `Export` is not a standard controller method. B. `Select` and `List` are not action methods provided by standard controllers. C. `Select` is not a valid action method. 🔗 Official Documentation: - [Standard Controller Methods](https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/apex_pages_standardcontroller.htm) 📚 Additional Resources: - [Visualforce Standard Controllers - Trailhead](https://trailhead.salesforce.com/content/learn/modules/visualforce_fundamentals/visualforce_standard_controllers) - [Using Standard Controllers in Visualforce](https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_std.htm)
30
A developer has uploaded a third-party JavaScript library as a static resource and references it in a Visualforce page using . Which of the following can be added to the page to call functions from the library? Choose 1 answer. A. ` ` B. ` ` C. `