Company: Walmart_SDE_MCQ
Difficulty: medium
Bob is planning to design a system for various possible shapes and he has implemented the following code to create objects for two shapes (circle and triangle) based on the input received from the user. Code: CLASS Shape PUBLIC FUNCTION show() RETURN ENDCLASS CLASS Circle INHERITS Shape PUBLIC FUNCTION show() PRINT "circle" RETURN ENDCLASS CLASS Triangle INHERITS Shape PUBLIC FUNCTION show() { PRINT "triangle"; RETURN ENDCLASS Now, he wants to include more shapes in his design and for each new shape he is required to implement a new class and recompile his code which is a bad practice in software design. Then which of the following ideas can he incorporate in his design to use the same common interface to create multiple new objects? Creating a static method to create different shape objects. Creating an abstract class with static member function to create the object. Creating a new class for each type of shape object. Creating a new class for each type of object inheriting a public pa