โ Back to Interfaces
Question 642
Factory Method Returning an Interface
Factory Method Returning an Interface
TheIShapeinterface declaresstring Name(), and theCircle(returnscircle) andSquare(returnssquare) classes implement it. Complete theShapeFactory.Createmethod so it returns aCirclewhenkindis"c"and aSquarefor any other value. The return type must beIShape. Do NOT write aMainmethod. Creating shapes for "c" then "s" prints: circle square
Expected Output:
circle square
Topics:
Interfaces
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cw, cr, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.