Given:
and
What is the result?
Given:
and
What is the result?
The compilation fails because the setValue method in the MyType class requires the type to be specified. The line 'type.setValue(1234)' tries to set an integer value to 'type', which is of type 'MyType<?>', leading to a compilation error since the compiler cannot ensure that the type parameter matches the given value type.
E is correct The method setValue(capture#1-of ?) in the type MyType<capture#1-of ?> is not applicable for the arguments (int)
MyClass.java:19: error: incompatible types: int cannot be converted to CAP#1 type.setValue(1234); ^ where CAP#1 is a fresh type-variable: CAP#1 extends Object from capture of ? Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output 1 error
Correct answer is E