0
0
LLDsystem_design~10 mins

Builder 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 Builder interface method for setting the product's name.

LLD
interface Builder {
    Builder setName([1] name);
}
Drag options to blanks, or click blank then click option'
AString
Bint
Cvoid
Dboolean
Attempts:
3 left
💡 Hint
Common Mistakes
Using int or boolean instead of String for the name parameter.
Using void as a parameter type.
2fill in blank
medium

Complete the code to return the built product from the Builder.

LLD
class ProductBuilder implements Builder {
    private Product product = new Product();

    public Product [1]() {
        return product;
    }
}
Drag options to blanks, or click blank then click option'
Acreate
Bbuild
CgetProduct
Dmake
Attempts:
3 left
💡 Hint
Common Mistakes
Using method names like create or make which are less standard.
Using getProduct which is verbose and less idiomatic.
3fill in blank
hard

Fix the error in the Director class method to correctly use the Builder to construct a product.

LLD
class Director {
    public Product construct(Builder builder) {
        builder.setName("Toy");
        builder.setPrice(10);
        return builder.[1]();
    }
}
Drag options to blanks, or click blank then click option'
Amake
Bcreate
Cget
Dbuild
Attempts:
3 left
💡 Hint
Common Mistakes
Using create() or make() instead of build().
Forgetting to call the method to return the product.
4fill in blank
hard

Fill both blanks to complete the fluent interface methods in the Builder implementation.

LLD
class ProductBuilder implements Builder {
    private Product product = new Product();

    public Builder setName([1] name) {
        product.name = name;
        return [2];
    }
}
Drag options to blanks, or click blank then click option'
AString
Bthis
Cproduct
Dvoid
Attempts:
3 left
💡 Hint
Common Mistakes
Returning void instead of this breaks chaining.
Using wrong parameter types like product or void.
5fill in blank
hard

Fill all three blanks to complete the dictionary comprehension that maps product names to prices for products costing more than 100.

LLD
expensive_products = {product.[1]: product.[2] for product in products if product.[3] > 100}
Drag options to blanks, or click blank then click option'
Aname
Bprice
Dquantity
Attempts:
3 left
💡 Hint
Common Mistakes
Using quantity instead of price in the condition.
Mixing up keys and values in the dictionary comprehension.