• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

any suggestions on this "outer class"

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 {...}
}
 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 {}
 
Monisha Talwar
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
reply
    Bookmark Topic Watch Topic
  • New Topic