Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam CRT-450 All Questions

View all questions & answers for the CRT-450 exam

Exam CRT-450 topic 1 question 87 discussion

Actual exam question from Salesforce's CRT-450
Question #: 87
Topic #: 1
[All CRT-450 Questions]

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. InsuranceRates.smokerCharge
  • B. rates.getSmokerCharge()
  • C. ContactTrigger.InsuranceRates.smokerCharge
  • D. rates.smokerCharge
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Abhishek36s
Highly Voted 2 years, 5 months ago
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.
upvoted 16 times
...
NEWBIEGUY
Highly Voted 2 years, 9 months ago
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
upvoted 5 times
khoce
2 years, 6 months ago
the variable is static and is only accessible as shown in the answer A no instance needed
upvoted 7 times
...
...
Ankit_Swami
Most Recent 4 months, 2 weeks ago
Selected Answer: A
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.
upvoted 1 times
...
SS1121
4 months, 3 weeks ago
Selected Answer: A
A is correct.
upvoted 1 times
...
ABHI0O07
7 months, 3 weeks ago
a.BECAUSE SMOKERcHARGE IS A STATIC VARIABLE
upvoted 1 times
...
1vanTT
1 year, 6 months ago
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"
upvoted 3 times
...
smoota
1 year, 9 months ago
Selected Answer: D
correct answer is D, b/c the InsuranceRates is instatiated by rates.
upvoted 2 times
Nand072
1 year, 3 months ago
Wrong, static variable are not accessed via instance. It's only via the class. Basic OOP.
upvoted 4 times
Oldscool8
7 months, 3 weeks ago
Spot on.
upvoted 1 times
...
...
...
Therrudy1994
2 years, 6 months ago
Just tried the code in dev console. A is the correct answer.
upvoted 5 times
...
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.

SaveCancel
Loading ...