Valid PDI Dumps shared by EduDump.com for Helping Passing PDI Exam! EduDump.com now offer the newest PDI exam dumps, the EduDump.com PDI exam questions have been updated and answers have been corrected get the newest EduDump.com PDI dumps with Test Engine here:
A developer must create a ShippingCalculator class that cannot be instantiated and must include a working default implementation of a calculate method, that sub-classes can override. What is the correct implementation of the ShippingCalculator class?
Correct Answer: C
Explanation the extending class can override the existing virtual methods by using the override keyword in the method definition. Overriding a virtual method allows you to provide a different implementation for an existing methodhttps://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_extending.htm
Recent Comments (The most recent comments are at the top.)
CORRECT ANSWER IS - D: Public abstract class ShippingCalculator { public void calculate() { /*implementation*/ } }
Explanation Why Correct: D: This option correctly defines an abstract class with a concrete method `calculate`. The method is not abstract, meaning it provides a default implementation that can be used or overridden by subclasses. In Apex, abstract classes cannot be instantiated, which meets the requirement.
INCORRECT OPTIONS: A: This is not correct as `override` is used when a subclass is overriding a method from a superclass, not within the abstract class itself.
B: This is not correct because `virtual` is used to allow a method to be overridden, but the class should not be abstract if it provides a default implementation.
C: This is also not correct because an abstract method cannot have an implementation, and the requirement is to have a working default implementation.
Recent Comments (The most recent comments are at the top.)
B is the correct answer
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_example.htm
CORRECT ANSWER IS -
D: Public abstract class ShippingCalculator {
public void calculate() { /*implementation*/ }
}
Explanation Why Correct:
D: This option correctly defines an abstract class with a concrete method `calculate`. The method is not abstract, meaning it provides a default implementation that can be used or overridden by subclasses. In Apex, abstract classes cannot be instantiated, which meets the requirement.
INCORRECT OPTIONS:
A: This is not correct as `override` is used when a subclass is overriding a method from a superclass, not within the abstract class itself.
B: This is not correct because `virtual` is used to allow a method to be overridden, but the class should not be abstract if it provides a default implementation.
C: This is also not correct because an abstract method cannot have an implementation, and the requirement is to have a working default implementation.
B is the correct Answer
B is the correct Answer