Exam 1z0-819 All QuestionsBrowse all questions from this exam
Question 205

Given:

What is the result?

    Correct Answer: D

    The code will produce a compilation error because variables used in lambda expressions must be final or effectively final. In this case, 's' is modified after the lambda expression is defined, making it not effectively final.

Discussion
OmnisumemOption: D

tested

ASPushkinOption: D

right answer is D Local variables decalred in the enclosing method, including its formal parameters, can be accessed in a lambda expression provided and they are effectively final This one : String s = "Oracle"; Runnable r = () -> { System.out.println(s); }; //s = "Java"; Thread t = new Thread(r); t.start() will be ok

d7bb0b2

that is ok, variables in lambdas must be a final or effectively final. If s is modified then code not compile

d7bb0b2Option: D

variables in lambdas must be a final or effectively final. If s is modified then code not compile