I was assuming that you were using *two* separate class files to store class *a* and class *b* i.e. a.java and b.java respectively. The reason being looking at the following code posted earlier there were two package statements.
And it is not possible to have more than one package statement in the same file. Hence my assumption that you were referring to two separate source code files.
Originally posted by Hansika Motwani:
2) 2. Secondly, if you have the package in D: drive as "d:\p\a.class"
where "p" is the package name. Then from command line you can execute the a.class using the fully qualified name of the class which is "p.a"
F:\>java -cp D:\ p.a
or you can set D:\ in the classpath environment variable and say
F:\>java p.a
Note: the -cp option used in the command line overrides the settings of the classpath environment variable.
iam not getting this ..is this right..
The above statement without relating to your actual question (which is different from what i earlier interpreted)is perfectly fine. Please specify where you are doubtful.
Now coming to your actual question:
Yes if the above two classes are in the same source file then the compiler will generate two class files.
The above source code if saved in a.java and compiled as javac a.java will give three class files including *a$inner.class*. If you declare an enum even that will be compiled into a separate class file.
So you don't have to explicitly compile class *b* included in a source file saved by the name a.java as you don't have any means of doing that. Compiler does that for you and compiles class *b* as a separate binary.
Hope it makes sense to you...