← Back to Interfaces
Question 732
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 the output shown in Expected Output.
Expected Output:
circle square
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Interfaces
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · 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.