A good answer might be:

  • What is the command that runs the Java compiler?
    • javac
  • What is the command that runs the Java interpreter?
    • java

Syntax Errors

It is likely that you will do something wrong. Here is the sample program with a deliberate error:


Class Hello
{
  public static void main ( String[] args )
  {
    System.out.println("Hello World!");
  }
}

The required word "class" has been changed to "Class" with a capital "C". This is called a syntax error. A syntax error is a "grammatical error" in using the programming language. Here is what happens when the mistaken program is compiled:
C:\Temp>javac Hello.java

  compiling: Hello.java
Hello.java:1: Class or interface declaration expected.
Class Hello
^
1 error
The compiler tried to translate the source code into bytecode but got confused when it got to a captial "C" it did not expect. The error message is not very clear. They never are. But at least it shows where the compiler got confused. The compiler will not have created a new bytecode file because it stopped translating when it got to the error.

QUESTION 5:

To fix this error and run the program what must you do?

Click Here after you have answered the question