2.1 Java terminology and environment

Introduction to Java

Object Oriented Programming (OOP) language.


Java technology

As programming language.

Java architecture

Java source code

Java compiler

Java bytecode (Object code)

Java Virtual Machine (JVM)

Program written in the form of text using Java.

Used to convert source code into binary program that consists of byte code. It creates .class file.

Bytecode is a set of instructions that are machine-independent. Executed by JVM.

Is a Java runtime system. Converts the bytecode in .class file to machine language.

Key concept of Java

Platform-Independent

Object-Oriented

Distributed

Secure

Simple

Portable

Multi-threaded

As development environment.

As application environment.

Robust

Bytecode and basic data types in Java makes it compatible.

Java programs written in one environment can run on all other environments.

Early and dynamic checking during runtime eliminates situations that cause errors.

Reliable.

To design programs close to the real world.

Powerful language.

To share and access data across the net.

Easy to learn and use.

To handle many tasks simultaneously.

Highly secure programming language.

Anatomy of Java program

Comment

Reserved Word

Modifiers

Statements

Blocks

Classes

Method

Main Method

Two slashes (//) in a line, or enclosed between / and / in one or multiple lines.

Sees //, it ignores all text after // in the same line.

Sees /, it scans for the next / and ignores any text between / and /.

Specific meaning to the compiler.

Cannot be used for other purposes in the program.

Specify the properties of the data, methods, and classes.

Ex: public and static.

An action or a sequence of actions.

Ex: System.out.println("Welcome to Java!") is to display the greeting "Welcome to Java!" .

All statement ends with semicolon(;)

Forms a block that groups components of a program.

Performs a sequence of operations to display a message.

Template or blueprint for objects.

Essential Java construct.

The main() method must be declared to be public and static.

Style and convention

Block styles

Appropriate comments and comments style

Naming conventions

Proper indention and spacing

Single-Line Comments

End-Of-Line Comments

Block Comments

Two spaces should be used

Start with a character (A-Z, a-z), an underscore (_) or a dollar sign ($).

Keywords cannot be used as identifiers.

Special characters like #, !, @ and ^ cannot be used.

Simple and easy to understand.

runs on a wide variety of operating environments.