A developer has the following class and trigger code:public class InsuranceRates {public static final Decimal smokerCharge = 0.01;}trigger ContactTrigger on Contact (before insert) {InsuranceRates rates = new InsuranceRates();Decimal baseCost = XXX;}Which code segment should a developer insert at the XXX to set the baseCost variable to the value of the class variable smokerCharge?
A. Rates.smokerCharge
B. Rates.getSmokerCharge()
C. ContactTrigger.InsuranceRates.smokerCharge
D. InsuranceRates.smokerCharge

Respuesta :

Answer:

InsuranceRates.smokerCharge

Explanation:

To set the baseCost variable to the value of the class variable smokerCharge, the developer needs to replace

Decimal baseCost = XXX;

with

Decimal baseCost = InsuranceRates.smokerCharge;

This is done using the class reference type.

The smokerCharge should be declared in the InsuranceRates class, at first.

For example Ball b;

And then, a new instance of the object from the class is created, using the new keyword along with the class name: b = new Ball();

In comparing to the example I gave in the previous paragraph, the object reference in the program is:

InsuranceRates rates = new InsuranceRates();

Because the smokerCharge is coming from a different class, it can only be assigned to the variable baseCost via the InsuranceRates class to give:

Decimal baseCost = InsuranceRates.smokerCharge;

ACCESS MORE