Interview Question
Software Engineer / DevelopersDid anyone notice: In java we can have main class more than once, of course in different public class. Invoking of the class is left to the user (entry Point).
That means if one mentions the public class that means that has the main as entry point.
Otherwise it would have been difficult to identify the entry point class in case of more such classes.
[Java classes contain intermediate code as byte code: can we relate it to this?]
any comments?
When we try to comiple a java file we will specify the file name
- Akhil Chityal November 20, 2009Ex :javac test.TestFile.java
When we issue the command, compiler assumes that this is class exists in the path test.TestFile and which is a public class. Compiler is an external system to your java file, so the file needs to be public.
If java allows more than one public class in a single source file, then it is very hard to identify the file location if the public class name not equal to the source file name.