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

Quiz: Nested and Anonymous Classes · Question 9 of 10

Where can a local class be used?

Where can a local class be used?

  1. A.Anywhere in the package
  2. B.Anywhere in the outer class
  3. C.Only in subclasses
  4. D.Only inside the method (block) where it is declared
Answer & explanation

Correct answer: Only inside the method (block) where it is declared

A local class is scoped like a local variable.

Can you get the rest right without peeking?

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

Start the quiz →