go to previous page   go to home page   go to next page hear noise highlighting

Answer:

  1. What should the source file be named?
    • AddUpNumbers.java
  2. What is the name of the bytecode file the compiler creates?
    • AddUpNumbers.class

Identifiers and Reserved Words

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

Most classes contain many more lines than this one. Everything that makes up a class is placed between the first brace  {  and its matching last brace  } .

The name of the class (and therefore the name of the file) is up to you. In programming, the name for something is called an identifier. An identifier is one or more characters long.

The first character of an identifier cannot be a digit. The remaining characters can be a mix of alphabetic characters, digits, underscore, and dollar sign $. No spaces are allowed inside an identifier.

It is conventional for a class name to start with a capital letter, but this is not required by the compiler. However, follow this convention so your programs are easier to understand. A source file should always end with .java in lower case.

A reserved word is a word like class that has a special meaning to the system. For example, class means that a definition of a class immediately follows. You must use reserved words only for their intended purpose. (For example, you can't use the word class for any other purpose than defining a class.)


QUESTION 3:

Which of the following look like good identifiers? (click on an identifier to verify your answer)


go to previous page   go to home page   go to next page