🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: static, final and Nested Classes: all 10 questions

Quiz: static, final and Nested Classes · Question 7 of 10

A lambda uses a local variable count from its method. What must be true about count?

A lambda uses a local variable count from its method. What must be true about count?

  1. A.It must be static
  2. B.It must be declared with the keyword final
  3. C.It must be effectively final (never changed after being set)
  4. D.It must be an object, not a primitive
Answer & explanation

Correct answer: It must be effectively final (never changed after being set)

Lambdas and anonymous classes can capture only final or effectively final local variables.

Can you get the rest right without peeking?

Take the timed Quiz: static, final and Nested Classes quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →