CJCoding With Joseph
15free / daySign inCreate account

Covariant Generic Interface

Make 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 — print one after the last line.

Hints2 available
Topics:
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.