A developer has the following class and trigger code. Which code segment should a developer insert at the XXX to set the baseCost variable to the value of the class variable smokerCharge?
A is correct.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_static.htm
A class static variable can’t be accessed through an instance of that class. If class MyClass has a static variable myStaticVariable, and myClassInstance is an instance of MyClass, myClassInstance.myStaticVariable isn’t a legal expression.
the answer is D not A. You are instantiating a reference to the class InsuranceRates as 'rates', which has a static variable named smokerCharge which is accessible outside of that class. As such, it would be rates.smokerCharge
A - Correct
A class static variable can’t be accessed through an instance of that class. If class MyClass has a static variable myStaticVariable, and myClassInstance is an instance of MyClass, myClassInstance.myStaticVariable isn’t a legal expression.
A is correct. verified it in the dev console. Option D won't even save, you will get the error "Static field cannot be referenced from a non static context: smokerCharge from the type InsuranceRates"
Just tried the code in dev console. A is the correct answer.
upvoted 5 times
...
This section is not available anymore. Please use the main Exam Page.CRT-450 Exam Questions
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Abhishek36s
Highly Voted 2Â years, 11Â months agoNEWBIEGUY
Highly Voted 3Â years, 2Â months agokhoce
2Â years, 11Â months agokira9708
Most Recent 1Â month agoAnkit_Swami
10Â months agoSS1121
10Â months agoABHI0O07
1Â year ago1vanTT
1Â year, 11Â months agosmoota
2Â years, 2Â months agoNand072
1Â year, 8Â months agoOldscool8
1Â year agoTherrudy1994
3Â years ago