Complete the code to declare an interface for payment processing.
interface PaymentProcessor {
void [1](double amount);
}The method name processPayment clearly describes the action in the interface.
Complete the code to declare a class that implements the PaymentProcessor interface.
class CreditCardProcessor implements PaymentProcessor { public void [1](double amount) { // Implementation details } }
The class must implement the method declared in the interface exactly as named: processPayment.
Fix the error in the code where the client uses the interface type to call the method.
PaymentProcessor processor = new CreditCardProcessor(); processor.[1](100.0);
The client calls the method defined in the interface, which is processPayment.
Fill both blanks to declare an interface and a class that implements it.
interface [1] { void processPayment(double amount); } class [2] implements [1] { public void processPayment(double amount) { // Implementation } }
The interface is named PaymentProcessor and the class implementing it is CreditCardProcessor.
Fill all three blanks to create a client code that uses the interface type to call the method.
public class PaymentClient { public static void main(String[] args) { [1] processor = new [2](); processor.[3](250.0); } }
The client declares the variable as the interface PaymentProcessor, instantiates CreditCardProcessor, and calls processPayment.