1z0-819 Exam QuestionsBrowse all questions from this exam

1z0-819 Exam - Question 110


Given:

and

What is the result?

Show Answer
Correct Answer: AE

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.

Discussion

3 comments
Sign in to comment
StavokOption: E
Jul 19, 2023

E is correct The method setValue(capture#1-of ?) in the type MyType<capture#1-of ?> is not applicable for the arguments (int)

ObaltOption: E
Feb 7, 2023

Correct answer is E

ASPushkinOption: E
Jun 5, 2024

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