You are on page 1of 89

 

        JAVA Principles


Encapsulation
Mechanism that
binds together code
and data
JAVA Principles
Encapsulation
The variables of a class
will be hidden from other
classes
They can be accessed only
through methods of their
current class.
JAVA Principles
JAVA Principles
Inheritance
Mechanism through which one
object acquires all the properties
and behaviors of parent object
JAVA Principles
Click to add text
Object Oriented
Programming through JAVA
History of JAVA
1991

OAK
Click to add text
Click to add text
Green
Java Coffee
 Java

Write Once, Run Anywhere


What is JAVA and Why we need this ?

 Object Oriented Programming Language


 Used in GUI, Web & Mobile applications
 Game Development
 Electronic Devices and so on…..
Editions of JAVA
Java Standard Edition SE

Java Enterprise Edition EE

Java Micro Edition ME


Versions of JAVA
JAVA SE 14  -
2020 
JAVA SE 8 - 2014
JAVA SE 6 - 2006
JAVA SE - 2006
JAVA 1.0 - 1995
JAVA Based Products

Click to add text


JAVA Based Products
JAVA Based Products
JAVA Based Products
         Syllabus
 What is JAVA?
UNIT-1
 History of java
 Byte Code
 JDK, JRE, JVM
 Java Buzz Words and Principles
 Variables & Data types
 Scope and Naming Conventions
 Operators
 Control Statements
 Arrays 
 Type Casting
UNIT-2
 Classes
 Objects
 Methods
 Method Overloading
 Constructor & Constructor
Overloading
 Static and this keyword
 Access Specifiers
 Garbage Collection
 String Class
Syllabus
UNIT-3
 Inheritance
 Types of Inheritance
 Usage of Super Keyword
 Method Overriding
 Abstract Classes
 Interfaces //
 Implementation of interfaces
 Packages
 Creating, Accessing and
Importing
Syllabus
UNIT-4
 Exception
 Types of Exception
 Try, catch and finally
 Throw and throws
 Exception Handling
 Thread
 Life cycle of a Thread
 Multithreading
Syllabus
UNIT-5

 Applets
 Events
 Swings
Java Execution Process ( BYTE
CODE)Java
Programming
Java Development kit

. Java file
Java Run-time Environment

Java Compiler

111100010
Byte Code Java Virtual Machine

.class file
Native Machine Code
JDK vs JRE vs JVM
 JDK- Environment to develop and run
 JRE- Environment only to run
 JVM- execute our Java Program

JDK
JRE +
Development tools

JVM+
Libraries
Variables
Storage
Container
Data Types
Data Types

Primitive Non-Primitive

Arrays
Boolean Numeric
Strings
Character Integral
boolean
Integer Floating Point
char
byte
short float
int double
long
Data Types
Siva owns a Retail Department store. He
need to create a bill with the following fields
present:

 Invoice ID       
 Product ID      
 Product Cost  
 Quantity          

 Total Price        
 Feedback Provided?  

Siva has no knowledge about data types in


Data Types
Siva owns a Retail Department store. He
need to create a bill with the following fields
present:

 Invoice ID integer
 Product ID integer
 Product Cost double
 Quantity integer
 Discount double
 Total Price double
 Feedback Provided? Boolean

Siva has no knowledge about data types in


Java Features
Java is easy to learn
Java Syntax is quite
simple
Easy to understand
Java Features
Java is an evolving System

Java is not done


Java Features
Java runs inside Virtual Machine which is
free from virus and stuff.

No use of Pointers
Java Features
Java Checks the code during compile and
run time

Java Completely takes care of


Memory Location
Java Features
Applications written on one platform can be
easily to ported to another
Java Features
Every thing in Java is performed using Objects

Easily extend as it is based on object model


JAVA Operators

JAVA
OPERATORS
JAVA Operators
Arithmetic Operator

 Addition +
 Subtraction -
 Multiplication *
 Division /
 Modulus %
JAVA Operators
Bitwise Operator

used to perform
manipulation of individual
bits of a number.

They can be used with any


of the integer types.
ARTHEMATIC  OPERATOR
 Java Arithmetic Operator Example
 class OperatorExample{  
 public static void main(String args[]){  
 int a=10;  
 int b=5;  
 System.out.println(a+b);//15  
 System.out.println(a-b);//5  
 System.out.println(a*b);//50  
 System.out.println(a/b);//2  
 System.out.println(a%b);//0  
 }}  
JAVA Operators
Bitwise Operator

 Bitwise AND &


 Bitwise OR |
 Bitwise XOR
^
 Bitwise
Complement ~
JAVA Operators
Bitwise Operator

a=5 b=7 0101 0111


a&b 0101(5)

a|b 0111(7)

a^b 0010 (2)

~a 1010 (-6)
JAVA Operators
Relational Operator

These operators are used to check for relations like equality,


greater than, less than.

They return boolean result after the comparison 


JAVA Operators
 Equal to == Relational Operator
 Not equal to !=
 Less than
<
 Less than or equal to
<=
 Greater than
>
 Greater than or equal to
>=
JAVA Operators
Ternary operator

 Ternary operator is a shorthand version of


if-else statement.
It has three operands and hence the name
ternary.
JAVA Operators
Any expression that evaluates
to a boolean value.

boolean_expression ? Expression_1 : expression_2

If true this expression is If false this expression is


evaluated and becomes the evaluated and becomes the
value entire expression. value entire expression.
JAVA Operators
Assignment Operator

Assignment operator is used


to assign a value to any
variable.

It has a right to left


associativity
JAVA Operators
Assignment Operator
a =5 b=7 c=10 d=9
1.class OperatorExample{  
2.public static void main(String args[]){  
3.int a=10;  
4.int b=5;  
 bitwise & operator
a += 21
5.int c=20;  
6.System.out.println(a<b&&a<c);
•System.out.println(a<b&a<c);//false & true = false  
b -=1
•}}  
C /= 5
d %= 9
JAVA Operators
Unary Operator
 Unary operators need only one
operand.

They are used to increment,


decrement or negate a value.
JAVA Operators
Unary Operator

 increment (pre /post) ++


Decrement (pre /post) --
Not (inverting a boolean value) !
JAVA Operators
unary Operator
a =10 b=11 c=12 d=13
v=false
a ++
++b
C --
--d
!v
JAVA Operators
Shift Operator

These operators are used to


shift the bits of a number left
or right
<< left shift

>> right shift


JAVA Operators
Shift Operator

0000 0101
a=5 b=5

a << 2
b >> 2
JAVA Operators
Logical Operator

These operators are used to


perform “logical AND” and
“logical OR” operation
Logical AND &&

Logical OR ||
JAVA Operators
boolean t = true;
boolean f = false;

(f && f)
(f && t)
(t && f)
(t && t)
JAVA Operators
boolean t = true;
boolean f = false;

(f || f)
(f || t)
(t || f)
(t || t)
JAVA Control Statements
JAVA Control Statements
JAVA Control Statements
JAVA Control Statements
JAVA Control Statements
JAVA Control Statements
JAVA Control Statements
JAVA Control Statements
JAVA Control Statements
JAVA Control Statements
JAVA Control Statements
JAVA Control Statements
JAVA Control Statements
JAVA Control Statements
JAVA Control Statements
JAVA Array

Array
JAVA Array
An Array is a data Structure which holds the
sequential elements of the same type
JAVA Array
JAVA Array
JAVA Type Casting

Type Casting
JAVA Type Casting

Converting one data type to another


data type

Small to big (Automatic)

Big to Small (MANUAL)


JAVA Type Casting
Type Casting: Small to Big

byte small =124

double big

big = small
JAVA Type Casting
Type Casting: Big to Small

double big = 15400

byte small

Small = big
JAVA Principles
Abstraction

Encapsulation

Inheritance

Polymorphism
JAVA Principles
Abstraction

Methodology of hiding the


implementation details from the user
and only providing the functionality
to the users
We use Abstract Class and
Interface to achieve
abstraction
JAVA Principles
         JAVA Principles+
Polymorphism

Ability of a variable , method or


object to take on multiple forms
JAVA Principles

You might also like