0
0
LLDsystem_design~10 mins

Abstract Factory pattern 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 the Abstract Factory interface method.

LLD
interface AbstractFactory {
    ProductA create[1]();
}
Drag options to blanks, or click blank then click option'
AProductA
BProduct
CProductB
DFactory
Attempts:
3 left
💡 Hint
Common Mistakes
Using a generic name like 'Product' instead of a specific product type.
Naming the method as 'Factory' which is incorrect.
2fill in blank
medium

Complete the code to implement a concrete factory method.

LLD
class ConcreteFactory1 implements AbstractFactory {
    public ProductA [1]() {
        return new ConcreteProductA1();
    }
}
Drag options to blanks, or click blank then click option'
AcreateProductB
BnewProductA
CcreateFactory
DcreateProductA
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong product creation method name.
Trying to create a product type not declared in the interface.
3fill in blank
hard

Fix the error in the client code to use the abstract factory correctly.

LLD
AbstractFactory factory = new ConcreteFactory1();
ProductA product = factory.[1]();
Drag options to blanks, or click blank then click option'
AcreateProductA
BnewProduct
CcreateProductB
DgetProductA
Attempts:
3 left
💡 Hint
Common Mistakes
Calling a method that does not exist in the factory interface.
Using a method name that does not correspond to the product type.
4fill in blank
hard

Fill both blanks to complete the Abstract Factory pattern with two product families.

LLD
interface AbstractFactory {
    ProductA [1]();
    ProductB [2]();
}
Drag options to blanks, or click blank then click option'
AcreateProductA
BcreateProductB
CnewProductA
DnewProductB
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent method naming.
Mixing 'new' and 'create' prefixes.
5fill in blank
hard

Fill all three blanks to complete the client code that uses Abstract Factory to create products and call their methods.

LLD
AbstractFactory factory = new ConcreteFactory1();
ProductA productA = factory.[1]();
ProductB productB = factory.[2]();
productA.[3]();
Drag options to blanks, or click blank then click option'
AcreateProductA
BcreateProductB
Cuse
Dexecute
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect method names for factory or product methods.
Calling methods that do not exist on the product.