1. Objectives
On completion of this period, you would be able to
know
• The process of entering and execution of a Java
program
• White spaces, separators, literals and keywords
• Comments in Java
9CM604.5 1
2. Recap
• What is a Byte Code
• What are the OOP Concepts
• Define Encapsulation
• Define Inheritance
• Define Polymorphism
9CM604.5 2
3. The Process of Entering and Executing a Java
Program
Entering a Java Program
• We can create a program using any text editor
• Let us assume we have entered the following
program
9CM604.5 3
4. The Process of Entering and Executing a Java
Contd..
Program
class Example
{
public static void main(String args[])
{
system.out.println(“Hello World”);
}
}
9CM604.5 4
5. The Process of Entering and Executing a Java
Contd..
Program
• We must save this program in a file called
Example.java
• Ensure that the file name contains the class name
• This file is called the source file
9CM604.5 5
6. The Process of Entering and Executing a Java
Contd..
Program
• All Java source files will have the extension .java
• If a program contains multiple classes, the file
name must be the class name of the class
containing the main method
9CM604.5 6
7. Executing a Java Program
Executing a Java Program involves two steps
1) Compiling a Java program
2) Running a Java program
9CM604.5 7
8. Compiling a Java Program
• To compile the program we must run with the
Java compiler ‘javac’ with the name of the source
file on the command line shown below
C: javac Example.java
9CM604.5 8
9. Executing a Java Program
• We need to use the Java interpreter to run a
stand alone program
• At the command prompt type
C: java Example
9CM604.5 9
10. Summary
• The process of entering and execution of a Java
program
• White spaces, separators, literals and keywords
• Comment statements in Java
9CM604.5 10
11. Quiz
1. Period . is a _________
a) Key Words
b) White Space
c) Separator
d) Comment
9CM604.5 11
12. Frequently Asked Questions
• Explain the process of entering and executing a
Java program
• Explain the separators in Java
• Write about white spaces in Java
• List any eight keywords in Java
• How can you write comments in Java
9CM604.5 12