It's not a secret anymore!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes any suggestions on this Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "any suggestions on this "outer class"" Watch "any suggestions on this "outer class"" New topic
Author

any suggestions on this "outer class"

anandkrisnan variar
Greenhorn

Joined: Feb 26, 2003
Posts: 16
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.
Monisha Talwar
Ranch Hand

Joined: Feb 11, 2003
Posts: 102
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.


Hey! It compiles! Ship it!
Reshma Shanbhag
Ranch Hand

Joined: Sep 17, 2002
Posts: 202
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 ]

SCJP 1.4, SCWCD 1.4
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
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
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...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: any suggestions on this "outer class"
 
Similar Threads
private protected??
inner class question...
explanation needed.
Outer Class
Confused on private modifier for classes