← 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 →- Q1. Which kind of nested class can be created without an object of the outer class?
- Q2. How do you create an object of the inner (non-static) class Account inside Bank?
- Q3. What does this print? (code)
- Q4. What does "effectively final" mean for a local variable used inside a lambda?
- Q5. What does this print? (code)
- Q6. Why is a static nested class usually preferred when the nested class does not use outer fields?
- Q7. Which of these CANNOT be implemented with a lambda?
- Q8. What does this print? (code)
- Q9. Where can a local class be used?
- Q10. In the Builder pattern, why is Pizza.Builder a static nested class rather than an inner class?