nerdexam
Salesforce

PDI · Question #167

A developer must create a CreditcardPayment class that provides an implementation of an existing Payment class. Public virtual class Payment { public virtual void makePayment(Decimal amount) {…

The correct answer is A. Public class CreditcardPayment extends Payment {. To provide an implementation of an existing virtual class, a new class must use the extends keyword for inheritance.

Submitted by stefanr· Apr 18, 2026Logic and Process Automation

Question

A developer must create a CreditcardPayment class that provides an implementation of an existing Payment class. Public virtual class Payment { public virtual void makePayment(Decimal amount) { /implementation/ } } Which is the correct implementation?

Options

  • APublic class CreditcardPayment extends Payment {
  • BPublic class CreditCardPayment implements Payment {
  • CPublic class CreditCardPayment extends Payment {
  • DPublic class CreditCardPayment implements Payment {

How the community answered

(50 responses)
  • A
    90% (45)
  • B
    2% (1)
  • C
    6% (3)
  • D
    2% (1)

Why each option

To provide an implementation of an existing virtual class, a new class must use the `extends` keyword for inheritance.

APublic class CreditcardPayment extends Payment {Correct

Since `Payment` is declared as a `virtual class`, `CreditcardPayment` must use the `extends` keyword to inherit from it and provide its own implementation for the `makePayment` method.

BPublic class CreditCardPayment implements Payment {

The `implements` keyword is used when a class adopts an interface, not when it inherits from another class.

CPublic class CreditCardPayment extends Payment {

This choice has the correct `extends` keyword but is structurally incomplete as a full class definition, assuming the intent was to differentiate `extends` from `implements`.

DPublic class CreditCardPayment implements Payment {

The `implements` keyword is used for interfaces; attempting to implement a class will result in a compile-time error.

Concept tested: Apex Class Inheritance

Source: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_defining.htm

Topics

#Apex#Classes#Inheritance#OOP

Community Discussion

No community discussion yet for this question.

Full PDI Practice