Study for the Salesforce Platform Developer Exam. Study with flashcards and multiple choice questions, each question has hints and explanations. Get ready for your exam!

Practice this question and more.


Which syntax represents a custom controller in VisualForce?

  1. <apex:page controller="MyController">

  2. <apex:page standardController="MyController">

  3. <apex:page customController="MyController">

  4. <apex:page privateController="MyController">

The correct answer is: <apex:page controller="MyController">

The syntax that represents a custom controller in VisualForce is to use the controller attribute within the apex:page tag. By specifying controller="MyController", you indicate that the page will utilize a custom Apex controller class called MyController. This tells Salesforce to instantiate and use this specific controller to manage data and actions for the VisualForce page. Custom controllers provide greater flexibility and control over the page's behavior compared to standard controllers, allowing developers to implement specific business logic and handle complex user interactions. The other options do not conform to the correct syntax for defining a custom controller, which is why they are not accurate representations. Therefore, the correct answer demonstrates the appropriate way to link a VisualForce page to a custom controller class.