File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Discuss the answer of a scjp concern run the program. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Discuss the answer of a scjp concern run the program." Watch "Discuss the answer of a scjp concern run the program." New topic
Author

Discuss the answer of a scjp concern run the program.

Gong James
Ranch Hand

Joined: Oct 15, 2001
Posts: 77
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
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
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.
 
Similar Threads
CONDITIONS
file argument to java program on the command line
What is the input file?
Mysql JDBC Cant load.....
how to run a compiled java program