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
that is ok, variables in lambdas must be a final or effectively final. If s is modified then code not compile
upvoted 1 times
...
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Omnisumem
3 months agod7bb0b2
6 months, 1 week agoASPushkin
6 months, 2 weeks agod7bb0b2
6 months, 1 week ago