~/ learn/ comp-308/ cards/ Interfaces as factories; nesting interfaces
1 of 4

Type the Fixable factory method

Type the Fixable factory method

Answer

public Fixable getFixable(int code) { switch (code) { case 1: return new FixWindow(); default: return new FixNothing(); } }

The declared return type is the interface Fixable; the concrete subclass chosen inside is invisible to the caller, who only ever holds a Fixable.

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/27f5163f-390e-4c37-893d-a9e195435bba/flashcard utf-8 LF