Discuss the answer of a scjp concern run the program.
Gong James
Ranch Hand
Joined: Oct 15, 2001
Posts: 77
posted
0
Q2 In order for the MyProgram program to be compiled and run, which of the following must be true? A the MyProgram class must be defined in MyProgram.java B MyProgram must be declared public. C My program must have a correctly formed main() method. D MyProgram must import java.lang. the given ans is: C my ans: A C
Fei Ng
Ranch Hand
Joined: Aug 26, 2000
Posts: 1241
posted
0
Originally posted by Gong James: Q2 In order for the MyProgram program to be compiled and run, which of the following must be true? A the MyProgram class must be defined in MyProgram.java B MyProgram must be declared public. C My program must have a correctly formed main() method. D MyProgram must import java.lang. the given ans is: C my ans: A C
Since B is not one of the answer then A isn't. only if the class is public then the name must be declared the same as the class.
Ragu Sivaraman
Ranch Hand
Joined: Jul 20, 2001
Posts: 464
posted
0
Good question.. You can have multiple classes in a single source file But if you have any one of the class to be public that class name MUST be the file name But in this case its just MyProgram compile and run so we dont need MyProgram.java. However main() is not required to be defined in the MyProgram class class A { public static void main(String args[]) { System.out.println("Good luck"); } } class MyProgram extends A{} Save in MyProgram.java OR A.java /compile/run it
Lemmeknow Ragu
[This message has been edited by Ragu Sivaraman (edited October 25, 2001).]
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: Discuss the answer of a scjp concern run the program.