• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Outer Class

 
Greenhorn
Posts: 11
  • 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 {...}
}
[ March 17, 2003: Message edited by: Michelle Joe ]
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As there can only be one public class declared in each file, and top-level classes may neither be declared private nor protected, there is only one remaining choice. If you don't specify any access modifier then the class has a "default" (package) access, that is, only the other classes in the same package may use that class.
 
Ranch Hand
Posts: 203
  • 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)?


a) If both classes are with default scope then your file name can be any thing you want.
b) If one of them is public then the other can only be defualt and the file name should match with the public class name.
You don't have any other option.
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just like any other member (attribute/ method) without a given acessmodifier an inner class
will have the default one, which is "package private".
 
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch J Isberg, please read the JavaRanch naming policy and adjust your displayed name accordingly. Thanks.
 
reply
    Bookmark Topic Watch Topic
  • New Topic