0
0
LLDsystem_design~10 mins

Program to interface not implementation in LLD - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare an interface for payment processing.

LLD
interface PaymentProcessor {
    void [1](double amount);
}
Drag options to blanks, or click blank then click option'
ApayAmount
BprocessPayment
CmakePayment
DexecutePayment
Attempts:
3 left
💡 Hint
Common Mistakes
Using method names that are too vague or unclear.
Using implementation details in the interface method name.
2fill in blank
medium

Complete the code to declare a class that implements the PaymentProcessor interface.

LLD
class CreditCardProcessor implements PaymentProcessor {
    public void [1](double amount) {
        // Implementation details
    }
}
Drag options to blanks, or click blank then click option'
ApayAmount
BexecutePayment
CprocessPayment
DmakePayment
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different method name than the interface.
Changing method parameters.
3fill in blank
hard

Fix the error in the code where the client uses the interface type to call the method.

LLD
PaymentProcessor processor = new CreditCardProcessor();
processor.[1](100.0);
Drag options to blanks, or click blank then click option'
AprocessPayment
BpayAmount
CmakePayment
DexecutePayment
Attempts:
3 left
💡 Hint
Common Mistakes
Calling a method name that exists only in the implementation class.
Using a method name not declared in the interface.
4fill in blank
hard

Fill both blanks to declare an interface and a class that implements it.

LLD
interface [1] {
    void processPayment(double amount);
}

class [2] implements [1] {
    public void processPayment(double amount) {
        // Implementation
    }
}
Drag options to blanks, or click blank then click option'
APaymentProcessor
BCreditCardProcessor
CDebitCardProcessor
DPaymentInterface
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent names between interface and class.
Using generic names that do not describe roles.
5fill in blank
hard

Fill all three blanks to create a client code that uses the interface type to call the method.

LLD
public class PaymentClient {
    public static void main(String[] args) {
        [1] processor = new [2]();
        processor.[3](250.0);
    }
}
Drag options to blanks, or click blank then click option'
APaymentProcessor
BCreditCardProcessor
CprocessPayment
DDebitCardProcessor
Attempts:
3 left
💡 Hint
Common Mistakes
Using the implementation class type for the variable instead of the interface.
Calling a method not declared in the interface.