Sunteți pe pagina 1din 31

Features of JAVA

PLATFORM INDEPENDENT LANGUAGE

OPERATING SYSTEM 1
JAVA RUNTIME
ENVIRONMENT (JRE)
JAVA javac BYTE java JAVA VIRTUAL
APP CODE MACHINE (JVM)
.java .class

OPERATING SYSTEM 2
JAVA RUNTIME
ENVIRONMENT (JRE)
javac java
JAVA BYTE JAVA VIRTUAL
APP CODE MACHINE (JVM)
.java .class
OBJECT ORIENTED PROGRAMMING

– ENCAPSULATION

– INHERITANCE
–Simple Inheritance
–Multi Level Inheritance
–Multiple Inheritance

– ABSTRACTION / POLIMORPHISM
• SECURED
– DATA ENCAPSULATION
– NO POINTERS
– NO UNAUTHORISED CODE

• ROBUST IN MEMORY MANAGEMENT


• MULTI THREADING PROGRAMMING
• GUI PROGRAMMING
• WEB BASED (APPLETS)
• HANDLING RUNTIME ERRORS
• NETWORK BASED APPLICATIONS
JAVA EDITIONS

JAVA
J2SE J2EE J2ME
Simple Programme in JAVA

import java.lang.*;
public class Hello
{
public static void main(String args[])
{
System.out.println(“Hello, Friend”);
}
}
How To Excecute a Programme
Set the path and classpath
PATH=%PATH%;c:\j2sdk1.4.0\bin
CLASSPATH=c:\j2sdk1.4.0\lib\tools.jar
Save
Hello.java
Compile
prompt:\> javac Hello.java
Execute
prompt:\> java Hello
Output
Hello, Friend
EXPRESSION
Expression:
An expression is a combination of
operators and operands.

c = a + b;

OPERANDS OPERATORS
VARIABLE
It is a reference to a value in the memory.
These are two types..
1. Instance Variables
Ex.: int a=5;
boolean b=false;
2. Reference Variables
Ex.: Circle c=new Circle();
Student stud=new Student();
Data Types
Type Memory Initials Value
• byte 1 byte 0
• short 2 bytes 0
• int 4 bytes 0
• long 8 bytes 0
• float 4 bytes 0.0
• double 8 bytes 0.0
• char 2 bytes nil
• boolean true / false false
Declaration of Variables
<data_type> <variable> = <initial_value>;
Example:
byte a = 5;
short b = 100;
int n = 5000;
long l = 10000;
float f = 5.5 f;
double d = 10.5; double d=10.5d;
char c = ‘a’;
boolean b = true;
OPERATORS
These are mainly categorized into 3 types as
– UNARY OPERATORS Ex: --, ++
– BINARY OPERATORS Ex: +, -, *, /
– TERNARY OPERATORS Ex: ? :

Types of operators according to functionality


– ARITHMATIC OPERATORS Ex: +, -, *, /, %, ++, --
– RELATIONAL OPERATORS Ex: ==, !=, <, >, <=, >=
– LOGICAL OPERATORS Ex: &&, ||, !
– BITWISE OPERATORS Ex: &, |, <<, >>, >>>
Example Programme
public class Add
{
public static void main(String args[])
{
int a=5;
int b=10;
int c=a+b;
System.out.println(“Sum is : ”+c);
}
}
OPERATORS
These are mainly categorized into 3 types as
– UNARY OPERATORS Ex: --, ++
– BINARY OPERATORS Ex: +, -, *, /
– TERNARY OPERATORS Ex: ? :

Types of operators according to functionality


– ARITHMATIC OPERATORS Ex: +, -, *, /, %, ++, --
– RELATIONAL OPERATORS Ex: ==, !=, <, >, <=, >=
– LOGICAL OPERATORS Ex: &&, ||, !
– BITWISE OPERATORS Ex: &, |, <<, >>, >>>
Branching Statements
switch…case statements:
switch
{
case <value>:
Statements;
[break];
case <value>:
Statements;
[break];
default:
Statements;
[break];
}
Conditional Statements
if Condition:
if(condition)
{
Statements;
if(condition) }
{ else
Statements; {
} Statements;
}
Conditional Statements
if(condition){ if(condition)
Statements; {
} if(condition)
else if(condition){ {
Statements; if(condition)
} {
Statements;
else{
}
Statements;
}
}
}
Iterative Statements
while statement:

while(true)
while(condition)
{
{
Statements;
Statements;
if(condition)
inc/dec/conf stmt;
break;
}
}
Iterative Statements
Do..while statement:

do
{
Statements;
inc/dec/conf stmt;
} while(condition);
Iterative Statements
For statement:

for(initialisation; condition; inc/dec)


{
Statements;
} for( ; ; )
{
Statements;
}
Iterative Statements
Nested Looping Statement:
for(initialisation; condition; inc/dec)
{
for(initialisation; condition; inc/dec)
{
Statements;
}
}
Iterative Statements
Nested Looping Statement:

for(initialisation; condition; inc/dec)


{
do
{
Statements;
inc/dec/conf stmt;
} while(condition);
}
Iterative Statements
Nested Looping Statement:

for(initialisation; condition; inc/dec)


{
while(condition)
{
Statements;
inc/dec/conf stmt;
}
}
Iterative Statements
Nested Looping Statement:

while(condition)
{
for(initialisation; condition; inc/dec)
{
Statements;
}
inc/dec/conf stmt;
}
Iterative Statements
Nested Looping Statement:
while(condition)
{
do
{
Statements;
inc/dec/conf stmt;
} while(condition);
inc/dec/conf stmt;
}
Iterative Statements
Nested Looping Statement:
do
{
while(condition)
{
Statements;
inc/dec/conf stmt;
}
inc/dec/conf stmt;
} while(condition);
Iterative Statements
Nested Looping Statement:
do
{
for(initialisation; condition; inc/dec)
{
Statements;
}
inc/dec/conf stmt;
} while(condition);
break

while(true) for( ; ; )
{ {
statements; statements;
if(condition) if(condition)
break; break;
statements; statements;
} }
break
abc: for(int i=0; i<10; i++)
{
for(int j=0; j<10; j++)
{
statements;
if(condition)
break abc;
statements;
}
}
continue

while(true) for( ; ; )
{ {
statements; statements;
if(condition) if(condition)
continue; continue;
statements; statements;
} }
continue
abc: for(int i=0; i<10; i++)
{
for(int j=0; j<10; j++)
{
if(condition)
continue abc;
}
}

S-ar putea să vă placă și