← Back to Interfaces
Question 789
Covariant Generic Interface
Covariant Generic Interface
Make the generic interfaceIProducer<T>covariant and completeStringProducer.Producemust return the string that was passed to the constructor. The interface must be covariant so that anIProducer<string>can be assigned to anIProducer<object>. Do NOT write aMainmethod. The tester creates aStringProducer("hello"), assigns it to anIProducer<object>variable, and prints the produced value (see Expected Output).
Expected Output:
hello= newline. The output ends with a newline — print one after the last line.
Hints2 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.