This week's giveaway is in the Testing forum.
We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line!
See this thread for details.
Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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...
 
He puts the "turd" in "saturday". Speaking of which, have you smelled this tiny ad?
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic