nerdexam
Salesforce

PDII · Question #197

A Visualforce Page throws an 'Attempt to dereference a null object' error for a Contact. What change in the controller will fix the error?

The correct answer is A. Use a condition in the getter to return a new Contact if it is null. See the full explanation below for the reasoning.

Question

A Visualforce Page throws an 'Attempt to dereference a null object' error for a Contact. What change in the controller will fix the error?

Options

  • AUse a condition in the getter to return a new Contact if it is null
  • BDeclare a static final Contact at the top of the controller
  • CChange the getter's signature to be static Contact
  • DChange the setter's signature to return a Contact

How the community answered

(28 responses)
  • A
    71% (20)
  • B
    11% (3)
  • C
    4% (1)
  • D
    14% (4)

Community Discussion

No community discussion yet for this question.

Full PDII Practice