This Edureka Java Tutorial will help you in understanding the various fundamentals of Java in detail with examples. Below are the topics covered in this tutorial:
1) Introduction to Java
2) Why learn Java?
3) Features of Java
4) How does Java work?
5) Data types in Java
6) Operators in Java
7) Control Statements in Java
8) Arrays in Java
9) Object Oriented Concepts in Java
2. `
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Agenda For Today
➢ Java Introduction
➢ Why Learn Java?
➢ Features of Java
➢ Java Development Kit
➢ How does Java work?
➢ Data Types in Java
➢ Operators in Java
➢ Control Statements
➢ Array in Java
➢ Object Oriented Concepts in Java
4. `
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Java Introduction
➢ Java was created by James Gosling in 1995 for Sun Microsystems.
➢ Java is a platform independent programming language that follows the logic of
“Write once, Run anywhere”.
Concurrent
Class
Based
Object
Oriented
11. `
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Features of Java
Simple
Java was designed to be easy for professional
programmer to learn and use effectively.
Portable
Applications written on one platform of Java can be
easily ported to another platform as it is platform
independent.
12. `
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Features of Java
Object-oriented
Java is an object oriented programming language. Everything is
considered to be an “object” and all operations are performed
using these objects.
Secure
Java does not use explicit pointer and runs its programs inside
the sandbox to prevents any activities from untrusted sources.
{OOPS}
13. `
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Features of Java
Distributed
Java has a feature called Remote Method Invocation (RMI)
using which a program can invoke method of another
program across a network and get the output.
Dynamic
Java programs carry with them substantial amounts of run-
time type information that is used to verify and resolve
accesses to objects at run time.
14. `
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Features of Java
Robust
➢ Java checks the code during the compilation time and run time also.
➢ Java completely takes care of memory allocation and releasing,
which makes the Java program more robust.
High performance
Java achieves high performance through the use of
bytecode which can easily translated into native machine
code.
18. `
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
How does Java work?
Java Source (.java)
Java Compiler
Java Bytecode
(.class)
Compile-time Environment
Java Bytecodes move locally
or through network
Class Loader
Bytecode
Verifier
Java Class Libraries
Java Interpreter
Just in Time
Compiler
Runtime System
Java Virtual
Machine
Run-time Environment
Operating System
Hardware
21. `
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Java Installation
To set the permanent path of JDK in your
system:
1. Begin by going to My Computer
Properties.
2. Click on Advanced system setting.
3. Click on Environment Variables
option
4. Select Path variable to edit
5. Enter the path to bin folder inside
JDK installed on your system.(
Default path is C:Program
FilesJavajdk1.8.0_121bin )
1
2
3
4
5
24. `
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Data Types in Java
Integer BooleanCharacterFloat
Primitive Data Type
byte (1 byte)
long (8 bytes)
short (2 bytes)
int (4 bytes)
float (4 bytes)
double (8 bytes)
char (2 byte)
bool (1 byte,
but makes use
of 1 bit of it)
float num = 56851.3285
char ch = ‘X’
boolean b = true
int num = 56
25. `
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
John owns a Retail Department store. John needs to create a bill with the following fields present:
➢ Invoice ID
➢ Product ID
➢ Product Cost
➢ Quantity
➢ Discount
➢ Total Price
➢ Feedback Provided ?
John has no knowledge about the data types in java,
Can you help John ?
Data Types in Java
26. `
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
John owns a Retail Department store. John needs 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
Data Types in Java
28. `
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Data Operations in Java
Data Operations
Arithmetic Operators
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus
Logical Operators
&& And
|| Or
! Not
Relational operators
< Less than
<= Less than or
equal to
> Greater than
>= Greater than
or equal to
!= Not equal to
== Equals
Unary operators
++ Increment
operator
-- Decrement
operator
29. `
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Data Operations in Java
Operation Solution
(Num1 + Num2) – Num3 / 5 20
Num1++ 11
Num3 >= Num1 + Num2 True
Num2 == Num1 False
(Num2 < Num3) && (Num1 > Num3) False
!Num4 False
Let us assume the following values for the variables:
➢ Num1 = 10
➢ Num2 = 15
➢ Num3 = 25
➢ Num4 = true
30. `
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Data Operations in Java
Mathew has come to John’s store to purchase a few products. Below are the items Mathew wishes to purchase :
Below are the cost of the products:
At the time Mathew visited the store, there was a 10% discount on all product.
Finally a service tax of 5% is applicable on all products.
Can you help John compute the amount Mathew has to pay ?
Product Quantity
Item A 2
Item B 1
Item C 3
Product Cost
Item A 200
Item B 75
Item C 500
33. `
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Syntax:
if (condition):
statements 1 …
else:
statements 2 …
1. If statement
Control Statement
If it is raining
Go Play Football
Take an Umbrella
START
Selection Statements
Iteration Statements
Jump Statements
Control Statement
FALSE
TRUE
34. `
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Control Statement
Syntax:
switch (expression) {
case value1: Statement1
break;
case value2: Statement2
break;
.
.
.
Selection Statements
Iteration Statements
Jump Statements
Control Statement
Outcome
of Toss
START
Head
Tails
Tom Wins
default
Adam Wins
Invalid input
FALSE
TRUE
FALSE
TRUE
2. Switch statement
35. www.edureka.co/pythonEDUREKA PYTHON CERTIFICATION TRAINING
LOOPS REPEAT ACTIONS
SO YOU DON’T HAVE TO ...
For
While
Repeat things until the
loop condition is true
Repeat things till the
given number of times
Control Statement
Do While
Execute once and then
repeats things until loop
condition is true
36. `
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Control Statement
Selection Statements
Iteration Statements
Jump Statements
Control Statement 3. do while statement
Syntax:
do
{
statements…
} while (condition is True)
CHECK
CONDITION
EXECUTE BLOCK
START
repeat
EXIT LOOP
FALSE
TRUE
37. `
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Control Statement
Selection Statements
Iteration Statements
Jump Statements
Control Statement
Syntax:
while (condition is True)
{
statements…
}
4. while statement
CHECK
CONDITION
EXECUTE BLOCK
START
repeat
EXIT LOOP
FALSE
TRUE
38. `
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Check
condition
Initialization
START
Iteration
Execute Statements
Exit loop
repeat
FALSE
TRUE
Selection Statements
Iteration Statements
Jump Statements
Control Statement 5. for statement
Syntax:
for(initialization; condition; iteration)
{
statements…
}
Control Statement
41. `
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Marry is a school teacher. She conducted the final exam for the year. The exam included the following subject:
Control Statement
Mathematics Chemistry Physics English
Computer
Science
Since there are multiple students, she wanted to create an automated system that will
take the marks for these subjects and provide a grade for the final score. Below is the
grade distribution :
Percentage Grade
Below 40 Poor
40-59 Average
60-79 Good
80-89 Very Good
90+ Excellent
Can you help me?
43. `
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Remember John ? Well now he has a great business running. John
now has a new challenge, he has 15 invoice number that he wants
to store the corresponding amount together but he doesn’t want to
store them using different number.
Array In Java
Can you help
me again?
44. `
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
An array is a data structure which holds the sequential elements of the same type.
Arrays of any type can be created and may have one or more dimensions.
Array In Java
0 1 2 3 4
126 32 230 21 200
Index
Value
E.g: array index 4 is
holding a value of 200
Each index in the array
holds a value.
45. `
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Arrays can be of 2 types:
Array In Java
Single Dimensional Array
Initialization: int a[] = new int[12] Initialization: int table[][] = new int[4][5];
Multi Dimensional Array
0 1 2 3 4
0
1
2
3
Width = 5
Height =4
Index in Y dimension
Index in
X dimension
47. `
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Blueprint of a house can be considered as a class With the Same blueprint we can create several houses and
these can be considered as objects
Class and Objects
➢ Java is an object oriented and class based programming language.
➢ Object is simply a collection of data (variables) and methods (functions) that act on those data.
➢ Class is a blueprint for the object.
48. `
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Super Class
Child Class
Inheritance
➢ Inheritance is a mechanism through which one object acquires all the properties and behaviors of
parent object.
➢ To avoid code redundancy, a derived class is developed upon a base class to achieve code reusability.
Amphibians Reptiles Mammals Birds
Animals
49. `
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Encapsulation
Methods Variable
Encapsulation
Class
➢ Encapsulation is the mechanism that binds together code and the data it manipulates together.
➢ In encapsulation, the variables of a class will be hidden from other classes, and can be accessed only
through the methods of their current class.
51. `
https://www.edureka.co/java-j2ee-soa-trainingEDUREKA JAVA CERTIFICATION TRAINING
Abstraction
➢ Abstraction is the methodology of hiding the implementation details from the user and only providing
the functionality to the users.
➢ In java, we use abstract class and interface to achieve abstraction.