if there are 2 outer classes being defined in the same file as follows, what is the class modifier for "secondOuter" by default (e.g. private, protected)? public class FirstOuter {...} class SecondOuter {...} Then, what is the class modifier "Inner" by default (private, protected)? public class Outer { class Inner {...} }
Regards,<br />anand.<br />IBM Global Services India.
I am not sure I quite understood your question... 1. If you have more than 1 top level classes, only 1 can be public. The other can be private, protected or default access. When you say what is the default....well, when you have no access modifier, its the package access or default access and thats the default 2. For inner classes, you can have any access modifier - Public, Private, protected or default. Again if you don't give it any access modifier - it is the default access. Monisha.
Monisha, Most of what you have mentioned is right except for..
1. If you have more than 1 top level classes, only 1 can be public. The other can be private, protected or default access.
Top level classes can have either 'public' or no access modifier. If u declare a top level class with 'private' or protected modifier it gives a complie time error. Reshma [ April 08, 2003: Message edited by: Reshma Pai ]
A top-leval class can have public, abstract, final and strictfp modifiers. These are valid: public abstract strictfp class A {} public final strictfp class B {}
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Monisha Talwar
Ranch Hand
Joined: Feb 11, 2003
Posts: 102
posted
0
Woow! Thanks for correcting me Reshma...I don't believe myself ...Yep top level class can't be private or protected ! Thats the first thing you learn! Duh! And I plan to take the exam soon...