• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Top level class?  RSS feed

 
Ranch Hand
Posts: 509
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is said that a java source file can have many top level classes, but only 1 top level class can be made public, Why so?
 
Marshal
Posts: 59762
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do a search and you find this, this, this and doubtless many more, which answer it better than I would have.
 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Abhi vijay:
It is said that a java source file can have many top level classes, but only 1 top level class can be made public, Why so?



One wierd example but it should make the concept clear :

It like that you have ony one father and mother , so there can be only top level class from which you can inherit most of the properties,also father can have a parent class Grandfather hence if you go up the hierarchy you will find only one class.
similarily you will have one parent class from which you can derive most of the properties..

i hope this make clear
 
Campbell Ritchie
Marshal
Posts: 59762
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am afraid you have misunderstood the question, Harshit Rastogi. It said top-level classes, not superclasses.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!