Covariant Generic Interface
hardQuestion 789Make the generic interface IProducer<T> covariant and complete StringProducer. Produce must return the string that was passed to the constructor. The interface must be covariant so that an IProducer<string> can be assigned to an IProducer<object>. Do NOT write a Main method.
The tester creates a StringProducer("hello"), assigns it to an IProducer<object> variable, and prints the produced value (see Expected Output).
Expected output
hello= newline. The output ends with a newline, so 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.