If the following program is saved in file named "HelloWorld.java", what are the commands for compiling it and running it.
// HelloWorld.java class Helloworld { public static void main(String s[]) { System.out.println("Hello World"); } }
javac HelloWorld.java java HelloWorld
javac HelloWorld.java java Helloworld
javac HelloWorld.java java HelloWorld.java
javac HelloWorld.java java Helloworld.java
Correct Answer : B
As the file name is HelloWorld.java we must compile it using HelloWorld.java that is javac HelloWorld.java.
The class having main method is named Helloworld (notice that w in world is small letter). In order to run we need to give the class name having main method. So we run it using class name i.e., java Helloworld.