nerdexam
Salesforce

CRT-450 · Question #24

A developer is implementing an Apex class for a financial system. Within the class, the variables creditAmount' and debtAmount' should not be able to change once a value is assigned. In which two…

The correct answer is B. Use the final keyword and assign its value in the class constructor. D. Use the final keyword and assign its value when declaring the variable. See the full explanation below for the reasoning.

Question

A developer is implementing an Apex class for a financial system. Within the class, the variables creditAmount' and debtAmount' should not be able to change once a value is assigned. In which two ways can the developer declare the variables to ensure their value can only be assigned one time? Choose 2 answers

Options

  • AUse the static keyword and assign its value in the class constructor.
  • BUse the final keyword and assign its value in the class constructor.
  • CUse the static keyword and assign its value in a static initializer.
  • DUse the final keyword and assign its value when declaring the variable.

How the community answered

(59 responses)
  • A
    19% (11)
  • B
    71% (42)
  • C
    10% (6)

Community Discussion

No community discussion yet for this question.

Full CRT-450 Practice