Professional Documents
Culture Documents
1
2
FIRST GENERATION – MACHINE LANGUAGE
Uses binary codes to instruct the machine
SECOND GENERATION – ASSEMBLY LANGUAGE
Uses mnemonic symbols to instruct the machine
Uses an assembler to convert codes to machine
language
THIRD GENERATION – HIGH LEVEL LANGUAGE
Uses a more simpler codes to instruct the machine
Uses a compiler or interpreter to convert codes to
machine language
3
What is Java?
Java is a high level programming language developed
by Sun Microsystems in the early 1990’s.
1. Simple
2. Platform Independent
3. Robust
4. Secure
5. Multithreading
6. Automatic Garbage Collection
YOURSELF
INTRODUCTION TO JAVA LANGUAGE
12
A program is a sequence of instructions that
species how to perform a computation
13
The instructions, which we will call statements, look
different in different programming languages, but there are
a few basic operations most languages perform:
Input: Get data from the keyboard, or a file, or some other device.
Output: Display data on the screen or send data to a file or other device.
Testing: Check for certain conditions and run the appropriate sequence of
statements.
Syntax
Syntax consists of the rules for combining words
into sentences, or statements as they are more
usually called in programming language.
Semantics
Semantics define the rules for interpreting the
meaning of sentences.
Programming errors are called bugs
2. Runtime Errors
This kind of error occurs when we ask the computer to do
something that is illegal. These errors are detected at
runtime.
3. Logic Errors
This are also called as semantic error. It will compile and
run without generating error messages, but it will not do
the right thing. These errors are very hard to find because
the computer can’t detect it.
import java.io.*;
import java.util.*;
System.out.println(“Hello World”);
}
}
Keywords
Predefined identifiers are reserved by Java. You can’t use
these words as your identifiers.
abstract assert boolean break
byte case catch char
class const continue default
do double else enum
extends false final finally
float for goto if
implements import instanceof int
interface long native new
null package private public
protected return short static
strictfp super switch this
synchronized throw throws true
transient try void volatile
while
Separators
Informs the java compiler of the grouping of
program elements. (), {}, comments
Literals
Constant values in a program
Operators
Specify an evaluation or calculation to be
performed on data or object
java.util.*; - this package contains the IO
Standard Output
System.out.println( );
System.out.print
Example;
System.out.println(“Hello World”);
System.out.println(a);
System.out.print(“Java World”);
System.out.print(x);
Standard Input
Should declare the package and object
static Scanner scan = new Scanner(System.in);
▪ scan.nextInt() – accept integer input
▪ scan.nextLine() – accept string input
▪ scan.nextDouble() – accept double input
Example:
String name;
name = scan.nextLine()
INTRODUCTION TO JAVA LANGUAGE
27
An item whose values changes during the execution of a
program.
Variable declaration
Before using any variable, you must first declare it. This is done in a
variable declaration statement.
Example: int age;
double Celsius;
Variable Initialization
A variable can be initialized by giving a default value.
Example: int age = 12;
double Celsius = 3.0;
A data type describes the kind of data that will
fit into a variable.
-9223372036854775808 to
long 8 bytes
9223372036854775807
Operators:
Operators are tools for manipulating data. An
operator is a symbol which represents some
particular operation to be performed on the
data.