JAVA
JAVA
History
➢ James gosling is the father of java, and introduced in the year 1991.
➢ The software was named as green talk and the team which developed is
called green team. Later the software was renamed as Oak. Oak is a symbol
of strength and it is a national tree for Germany.
➢ There was already existing company called Oak technology which had
become a legal issues due to this legal issues they changed the software
name Oak to java.
➢ James gosling and his team went for a coffee to an island and the coffee
shop named was java hence they kept the software name as java , since they
went for a coffee they kept the coffee bug as a logo for the java software.
➢ Java is a high-level programming language originally developed by Sun
Microsystems and released in 1995. Java runs on a variety of platforms, such
as Windows, Mac OS, and the various versions of UNIX
Tokens
Token is the smallest unit of program.
In token we have,
1. Identifier 2. Keywords 3. Literals
4. Operators 5. Separators 6. Comments
1. Identifier
Identifier is a name given for the java program.
2. Keywords
Keywords are the pre – defined word which has its own meaning.
In java , we have 50 keywords as follows,
Page 1
,JAVA
Abstract continue for new switch
Assert default goto package synchronized
Boolean do implements private this
Break double import protected throw
Byte else instanceof public throws
Case enum int return transient
Catch extends interface short try
Char final long static void
Class finally native strictfp volatile
Const float new super while
3. Literals
Literals are the value which is used in java programming languages.
In literals we have,
1. Number literals: Integer literals → (9,8,7,6,5)
Decimal literals → (0.55, 0.75)
2. Character literals : enclosed in single quotes (‘ ‘) → (‘A’, ‘5’,’$’ ,’ ‘)
3. String literals : enclosed in double quotes (“ ”) → (“ Hello”, “$#*&”)
4. Boolean literals : TRUE, FALSE
4. Operators
Operator is a symbol which is used to perform some operations on the
operands.
Ex: 5 + 3 → operands
Operator
Page 2
,JAVA
Operator type Category Precedence
UNARY Postfix Expr++ , Expr--, ++Expr ,
Prefix -- Expr , +Expr , -Expr=!
ARITHMETIC Additive, */ % , + , -
multiplicative
SHIFT Shift << , >> , >>>
RELATIONAL Comparison < >, <=, >=, instance of
Equality ==, !=
BITWISE Bitwise AND , &
Bitwise exclusive OR, ^
Bitwise inclusive OR |
LOGICAL Logical AND &&
Logical OR ||
TERNARY Ternary ? :
ASSIGNMENT Assignment += , -= , *= , /= , %= , &= , ^ = ,
<<= , >>= , >>>=
5. Separators
Separators is used to separate the given code.
In java we have,
{ } → braces, [ ] → brackets, ( ) → parenthesis, ; → semicolon , ( , ) → comma
6. Comments
Comments are used to provide the additional information for the java
program.
In comments we have,
1. Single line comments
//……………..//
2. block line comments
/*………….*/
Page 3
, JAVA
Java architecture
➢ We will write the program in edit plus / notepad. It is also called as source
code which is in human readable format.
➢ To convert this human readable format into machine readable format, we
have to go to command prompt and perform 2 operations
1. Javac ( java compiler)
2. Java ( java interpreter)
➢ Once after writing the program we have to save the file with the extension of
.java in below path
c:/pgmfiles/java/ Jdk 1.8 / bin
➢ Once after saving we have to give this .java file as an input to the compiler
where it will check for 1). Syntax 2). Rules 3). Translate from .java to
.class file
➢ If there is any syntax or rules violation we get compile time error.
➢ If there is no violation then the .class file will be generated.
➢ .class is an intermediate code which is in byte code format which cannot
understood neither by human nor by machine.
➢ .class file will be given as input for the interpreter which 1). Reads line by
line 2). Execute ( JVM ) 3). Translate .class file to binary language.
➢ If we find any abnormal statements like 1/0 which is infinite , which is not
defined in java hence we get run time error called Arithmetic exception.
Page 4
JAVA
History
➢ James gosling is the father of java, and introduced in the year 1991.
➢ The software was named as green talk and the team which developed is
called green team. Later the software was renamed as Oak. Oak is a symbol
of strength and it is a national tree for Germany.
➢ There was already existing company called Oak technology which had
become a legal issues due to this legal issues they changed the software
name Oak to java.
➢ James gosling and his team went for a coffee to an island and the coffee
shop named was java hence they kept the software name as java , since they
went for a coffee they kept the coffee bug as a logo for the java software.
➢ Java is a high-level programming language originally developed by Sun
Microsystems and released in 1995. Java runs on a variety of platforms, such
as Windows, Mac OS, and the various versions of UNIX
Tokens
Token is the smallest unit of program.
In token we have,
1. Identifier 2. Keywords 3. Literals
4. Operators 5. Separators 6. Comments
1. Identifier
Identifier is a name given for the java program.
2. Keywords
Keywords are the pre – defined word which has its own meaning.
In java , we have 50 keywords as follows,
Page 1
,JAVA
Abstract continue for new switch
Assert default goto package synchronized
Boolean do implements private this
Break double import protected throw
Byte else instanceof public throws
Case enum int return transient
Catch extends interface short try
Char final long static void
Class finally native strictfp volatile
Const float new super while
3. Literals
Literals are the value which is used in java programming languages.
In literals we have,
1. Number literals: Integer literals → (9,8,7,6,5)
Decimal literals → (0.55, 0.75)
2. Character literals : enclosed in single quotes (‘ ‘) → (‘A’, ‘5’,’$’ ,’ ‘)
3. String literals : enclosed in double quotes (“ ”) → (“ Hello”, “$#*&”)
4. Boolean literals : TRUE, FALSE
4. Operators
Operator is a symbol which is used to perform some operations on the
operands.
Ex: 5 + 3 → operands
Operator
Page 2
,JAVA
Operator type Category Precedence
UNARY Postfix Expr++ , Expr--, ++Expr ,
Prefix -- Expr , +Expr , -Expr=!
ARITHMETIC Additive, */ % , + , -
multiplicative
SHIFT Shift << , >> , >>>
RELATIONAL Comparison < >, <=, >=, instance of
Equality ==, !=
BITWISE Bitwise AND , &
Bitwise exclusive OR, ^
Bitwise inclusive OR |
LOGICAL Logical AND &&
Logical OR ||
TERNARY Ternary ? :
ASSIGNMENT Assignment += , -= , *= , /= , %= , &= , ^ = ,
<<= , >>= , >>>=
5. Separators
Separators is used to separate the given code.
In java we have,
{ } → braces, [ ] → brackets, ( ) → parenthesis, ; → semicolon , ( , ) → comma
6. Comments
Comments are used to provide the additional information for the java
program.
In comments we have,
1. Single line comments
//……………..//
2. block line comments
/*………….*/
Page 3
, JAVA
Java architecture
➢ We will write the program in edit plus / notepad. It is also called as source
code which is in human readable format.
➢ To convert this human readable format into machine readable format, we
have to go to command prompt and perform 2 operations
1. Javac ( java compiler)
2. Java ( java interpreter)
➢ Once after writing the program we have to save the file with the extension of
.java in below path
c:/pgmfiles/java/ Jdk 1.8 / bin
➢ Once after saving we have to give this .java file as an input to the compiler
where it will check for 1). Syntax 2). Rules 3). Translate from .java to
.class file
➢ If there is any syntax or rules violation we get compile time error.
➢ If there is no violation then the .class file will be generated.
➢ .class is an intermediate code which is in byte code format which cannot
understood neither by human nor by machine.
➢ .class file will be given as input for the interpreter which 1). Reads line by
line 2). Execute ( JVM ) 3). Translate .class file to binary language.
➢ If we find any abnormal statements like 1/0 which is infinite , which is not
defined in java hence we get run time error called Arithmetic exception.
Page 4