Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
1
of 1 vote

When we try to comiple a java file we will specify the file name
Ex :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.

- Akhil Chityal November 20, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The reason why java allows only one public class in one .java file is that the name of your public class will be the name of your .java file. As you can not put more than one name of your .java file so you cant have more than one public class.

- Anonymous April 17, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

then it boils down to asking, "Why does java require the name of the .java file to be same as that of the Class?"

- smartAss July 17, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Did 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?

- master January 01, 2010 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More