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

Answer:


Example Source Program

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

Above is the source program (source file) from chapter 5 The program types the characters Hello World! on the monitor.

The file must be named Hello.java to match the name of the class, Hello On most computer systems, the upper and lower case characters of the file name are important. (So if the file is named hello.java with a small h it will not work). On all computers, upper and lower case inside a Java program are important.

A programming language where upper and lower case make a difference is called case sensitive. Java is case sensitive. Not all programming languages are.

Lines are indented to show the logical structure of the program. This is not required by Java, but makes the program easier to understand. (More on this later.)

The first line

public class Hello

says that this source program defines a class called Hello. A class is a section of a program that describes an object. (A more complete definition will come later on in these notes.) Small programs often consist of just one class. When the program is compiled the compiler creates a file of bytecodes called Hello.class.


QUESTION 2:

Here is the first line of another Java program:

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

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