โ Back to Interfaces
Question 699
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: hello
Expected Output:
hello
Topics:
Interfaces
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท 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.