Regarding Default access modifier

Hi All,

There is a rule saying that...there must be one public class per source file and the file name must match with the class name.

What about having a class with default access level?I have a file having only one class (same as the file name) with default access level.It is working fine...

My question is...With default access, a class can be accessed inside the same package, but not from outside.Then..How come JVM is able to run that class?

What am I thinking is correct? or Am I going wrong?

Can anybody make it clear?

Thanks

[577 byte] By [Vasanth_Reddya] at [2007-11-27 6:32:42]
# 1
> With default access, a class can be> accessed inside the same package, but not from> outside.Thats completely true. JVM is not a class, so the rule does not apply. The JVM interprets de code.
oropezaa at 2007-7-12 17:58:21 > top of Java-index,Java Essentials,New To Java...
# 2
What about the rule saying..There must be one public class per source file and the file name must match with the class name?
Vasanth_Reddya at 2007-7-12 17:58:21 > top of Java-index,Java Essentials,New To Java...
# 3

> What about the rule saying..

> There must be one public class per source file and

> the file name must match with the class name?

I think you have misinterpreted. You can have at most one public class per file. If one class is public then all others cannot be public.

floundera at 2007-7-12 17:58:21 > top of Java-index,Java Essentials,New To Java...