Review Questions

7.6 Which statement is true?

Select the one correct answer.

  1. Non-static member classes must have either default or public accessibility.

  2. All nested classes can declare static member classes.

  3. Methods in all nested classes can be declared static.

  4. All nested classes can be declared static.

  5. Static member classes can contain non-static methods.

7.7 Given the declaration
interface IntHolder { int getInt(); }

which of the following methods are valid?

 //----(1)---- IntHolder makeIntHolder(int i) { return new IntHolder() { public int getInt() { return i; } }; } //----(2)---- IntHolder makeIntHolder(final int i) { return new IntHolder { public ...

Get Programmer's Guide to Java™ Certification, A: A Comprehensive Primer, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.