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

Quiz: static, final and Nested Classes: questions with answers

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

Take the timed quiz + get a certificate →
  1. Q1. What does this print? (code)
  2. Q2. When does a static block run?
  3. Q3. What does this print? (code)
  4. Q4. Which statement about a blank final field is correct?
  5. Q5. How do you create an object of a (non-static) inner class Account declared inside Bank?
  6. Q6. Why is a static nested class often preferred over an inner class?
  7. Q7. A lambda uses a local variable count from its method. What must be true about count?
  8. Q8. What does this print? (code)
  9. Q9. Which can an anonymous class do that a lambda cannot?
  10. Q10. Can a top-level (not nested) class be declared static?