This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
What modifiers(private, public protected, or none(default), static, final, native, abstract) can we place for inner class(member inner class, local inner class, anonymous inner class) declaration. Can inner class have constructors. AAA. --Farooq
Muhammad Farooq<br />Sun Certified Programmer for Java 2 Platform<br />Oracle8i Certified Professional Database Administrator
For static inner classes (Top level) All 4 access modifiers are applicable For non static (nested inner classes) All 4 access modifiers are applicable For local static inner classes (i.e inner classes within static methods) There should'nt be any access modifier For local inner classes (i.e inner classes within non static methods) There should'nt be any access modifier For anonymous inner classes (i.e anonymous inner classes within static/non static methods) There should'nt be any access modifier Yes, inner classes can have constructors (except anonymous ones)
Asma Zafar,<BR>Sun Certified Programmer for Java2 Platform
Hi Muhammad, Inner classes can have any of the access modifiers (public, private, protected or none). They can also be final or abstract; but not both. If a nested class is declared with the static modifier; it becomes a static member class or top-level nested class (technically, an 'inner class' is a nested class declared without the 'static' modifier) A local inner class does not take any access modifier, it cannot be static. It can be declared abstract or final (but not both) All of the above can be declared with the strictfp modifier. Anonymous classes cannot be declared with any modifiers (or extends or implements clause). None of the above can be 'native' ... that modifier only applies to methods. Hope that helps. ------------------ Jane Griscti Sun Certified Programmer for the Java� 2 Platform