🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: Nested and Anonymous Classes: questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. Which kind of nested class can be created without an object of the outer class?
  2. Q2. How do you create an object of the inner (non-static) class Account inside Bank?
  3. Q3. What does this print? (code)
  4. Q4. What does "effectively final" mean for a local variable used inside a lambda?
  5. Q5. What does this print? (code)
  6. Q6. Why is a static nested class usually preferred when the nested class does not use outer fields?
  7. Q7. Which of these CANNOT be implemented with a lambda?
  8. Q8. What does this print? (code)
  9. Q9. Where can a local class be used?
  10. Q10. In the Builder pattern, why is Pizza.Builder a static nested class rather than an inner class?