Jaworski (http://www.jaworski.com/java/certification/) has a question like In order of MyProgram to be compiled & run, which are true? Athe MyProgram class must be defined in MyProgram.java BMyProgram must be declared public CMyProgram must have a correctly formed main() met. DMyProgram must import java.lang and the answre is only B. is not A also correct?
Joined: Jun 26, 2000
Not necessarily, because the class could be defined in a package along with other classes, right?? Savithri
Joined: Jul 06, 2000
in a package,only one class can be public.and that class name is used to name the file.so,...i think 'a' is also correct.what do u say?
Joined: Sep 25, 2000
Hi, I think C should be the only condition. -Maha
Joined: Jun 30, 2000
It is not C because you don't have to have a main like with applets. It is not D because you don't have to import java.lang. Now for A and B. I would think 'A' would be true because the question says in order to run and compile MyProgram. If you are running MyProgram then you would have to have it in a file MyProgram.java, correct? When I tried doing this, I got a NoClassDefFound runtime error. As for 'B', I don't think B is correct because a class can be a 'friendly' class and still compile and run. It can't be private or protected, but it can be 'friendly' or public. So I would have said only 'A' is correct.