Complete the code to declare the Abstract Factory interface method.
interface AbstractFactory {
ProductA create[1]();
}The Abstract Factory declares a method to create a product, here named createProductA to produce ProductA type.
Complete the code to implement a concrete factory method.
class ConcreteFactory1 implements AbstractFactory { public ProductA [1]() { return new ConcreteProductA1(); } }
The concrete factory implements the method createProductA to return a specific product variant.
Fix the error in the client code to use the abstract factory correctly.
AbstractFactory factory = new ConcreteFactory1();
ProductA product = factory.[1]();The client calls createProductA on the abstract factory to get the product instance.
Fill both blanks to complete the Abstract Factory pattern with two product families.
interface AbstractFactory {
ProductA [1]();
ProductB [2]();
}The abstract factory declares creation methods for both ProductA and ProductB families.
Fill all three blanks to complete the client code that uses Abstract Factory to create products and call their methods.
AbstractFactory factory = new ConcreteFactory1(); ProductA productA = factory.[1](); ProductB productB = factory.[2](); productA.[3]();
The client calls createProductA and createProductB to get products, then calls use on ProductA.