SlideShare a Scribd company logo
Hello Everyone!
Welcome to TECHFORT’s
Training
Hello Everyone!
JAVA
Sujit Majety,
Technical Head / Corporate Trainer
Day 1 Agenda
Introduction to Java
• Introduction
• Programming Paradigm
• History
• Features
• Sample Program
• Execution Steps
• JVM
• Data types
• Objects and Classes
• Variables
• Flow Control Statements
Java Introduction
Day 1 : Agenda
Introduction
Lets start our exiting journey from now.
Introduction
•Java is one of the most powerful programming languages.
•Java is cross-platform, object-oriented, network-based,
reliable programming language.
•The slogan of java is “write once and run anywhere”, this
allowed java to gain enormous popularity. Its rapid
ascension and wide acceptance can be traced to its design
and programming features.
•The name “JAVA” came from the name of the coffee seed.
•JAVA released to market in different platforms.
Java Platforms
•A java platform or edition consists of a JRE with a specific set
of libraries for a specific application environment.
PLATFORM KEY CHARACTERISTICS
J2SE Core Java platform designed for applications running on desktop PCs.
J2EE Design, development, assembly, and deployment of business Applications.
J2ME Design of small, embedded applications in consumer devices (such as
mobile phones).
Java Card Design of small Java applications that run on smart cards.
JavaFX Design of Rich Internet Applications (RIAs).
Programming Paradigm
A way of conceptualizing what it means to perform computation
Programming Paradigms
Procedure Oriented
• More emphasis on algorithms.
• Programs divided into functions.
• Most functions share data, less security
to data.
• Data move around the system
between functions, any function can
change the data.
• Adding new code is very difficult.
• Code cannot be re-used.
• E.g. C, VB, Perl, Basic, Fortran
Object Oriented
•More emphasis on data.
•Programs are divided into objects.
•Functions operate on data are tied
together in the data structure.
•Data is secured; it is hidden to external
functions, can be accessed by functions
tied to it.
•Adding new code is very easy.
•Code can be re-used.
•E.g. CPP, Java, VB.Net, C#.Net
History
Where did this start?
History
•Developed by a team led by James Gosling at Sun
Microsystems.
•Sun Microsystems was a company best known for its
workstations.
•Java was originally OAK, designed for use in embedded
consumer electronic application in 1991.
•OAK was redesigned for developing internet applications
and renamed JAVA in 1995.
•Java is inherently object-oriented.
History
Major Release Date Key Characteristics
JDK 1.0 1996 First stable version of Java
JDK 1.1 1997 Inner classes; Java beans; JDBC; RMI; Just in Time (JIT) compiler for Windows
platforms
JDK 1.2 1998 Swing classes; Java IDL; Collections
JDK 1.3 2000 Java platform debugger architecture (JPDA); JavaSound; HotSpot JVM
JDK 1.4 2002 Regular expressions; IPv6 support; image I/O API; non-blocking I/O (nio); XML parser
and XSLT processor
JDK 5.0 2004 Generics; annotations; autoboxing; enumerations; varargs; for each loop
JAVA SE 6 2006 Improved GUI support; improved web service support
JAVA SE 7 2011 New file I/O capabilities; support for new network protocols
JAVA SE 8 2014 Lambda expressions; new date and time API
JAVA SE 9 2016
(expected)
Money and currency API
Features
Features
There are eleven promising features in java
• Simple (no pointers, interfaces, rich set of API, friendly syntaxes)
• Secure (many number of security mechanisms to block stray programs)
• Portable (can run on any operating system)
• Robust (memory management, exceptional handling)
• Distributed (runs on multiple servers and can be accessed by no of clients)
• Interpreted (both compiled and interpreted)
• Multi Threading (multiple flow of controls)
• Dynamic (is always open for updating)
• Architecture Neutral (can run on any processor)
• High Performance (garbage collector, leaves resources wile waiting for inputs)
• Object oriented (everything is written in class)
Our First Java Program
First Java Program
public class Test {
public static void main(String[] args) {
System.out.println("HELLO WORLD");
}
}
javac Test.java
Java Test
HELLO WORLD
Execution Steps
Execution Steps
Text editor
Java
Virtual
Machine
Java
Compiler
Source Code
(.java)
Byte code
(.class)
Output on
Console
Saves Java statements
Produces
Result in
JVM
JVM
•JVM stands for Java Virtual Machine.
•It is abstract machine.
•It is a specification that provides runtime environment in which
java byte code can be executed.
•JVM’s are available for many hardware and software platforms
(i.e. JVM is platform dependant).
•JVM performs four main tasks,
Loads code
Verifies code
Executes code
Provides runtime environment.
JVM
Class
file
Class Loader
Subsystem
Runtime
Data
areas
Method
area
Heap Stack
PC
Registers
Native
Method
area
Execution Engine
JVM JIT
Data Types
Data Types
• Java supports UNICODE character set. Hence, each character is
represented in two bytes.
• In java every variable has a type, every expression has a type and all
assignments should be checked by the compiler for type compatibility.
Hence, java is treated as strongly typed language.
• We are having 8 primitive data types.
• These data types fall under 3 categories.
• Numeric Data types
• Character Data types
• Boolean Data types
Data Types
DATA TYPE SIZE RANGE DEFAULT VALUE
byte 8 bit -128 to 127 0
short 16 bit -32768 to 32767 0
int 32 bit -2,147,483,648 to 2,147,483, 647 0
long 64 bit -9,223,372,036,854,775,808 to
9,223,372,036,854,775,807
0L
float 32 bit approximately ±3.40282347E+38F 0.0f
double 64 bit approximately
±1.79769313486231570E+308
0.0d
char 16 bit 0 to 65,536 (unsigned) ‘u0000’
boolean not precisely
defined
true or false false
Object Oriented Programming
OOP
• Object oriented programming models the real world.
• Object oriented programming organizes a program around its data and set of well
defined interfaces to that data.
• An object-oriented program can be characterized as data controlling access to
code.
• By switching the controlling entity to data, you can achieve several organizational
benefits.
• Object oriented programming, the first letter indicates object.
• What is an object?
Object
•An object is the basic unit of object orientation with
behaviour and identity.
•An object is a real time entity. E.g.. Car, bike, book, me
and you.
•It is a runtime entity that has a state and behaviour.
•The state of the object represents the data.
•The behaviour is represented by the methods.
•E.g. An object is created to represent a rabbit.
It would have data: how hungry it is, where it is.
And methods : eat, hide, run and dig.
Class
• A class is a way of binding the data and associated methods into a
single unit.
• A class can also be said as a blue print to create an object.
• If we want to develop a java program, then that should be developed
with respective of class only. i.e. without class there is no java program.
• Syntax:
class <class_name>
{
Variable declaration;
Methods definition;
};
Class Name
Data members/
properties/
Attributes
Behaviours/
Methods
Animal
Name,
Number of legs,
Colour
Eat(),
Walk(),
Sleep()
Example
class Bicycle {
int cadence = 0;
int speed = 0;
int gear = 1;
void changeCadence(int newValue) {
cadence = newValue;
}
void changeGear(int newValue) {
gear = newValue;
}
void speedUp(int increment) {
speed = speed + increment;
}
void applyBrakes(int decrement) {
speed = speed - decrement;
}
void printStates() {
System.out.println("cadence:" +
cadence + " speed:" +
speed + " gear:" +
gear);
}
}
Variables
Variables
•A variable is a name given to a memory location.
•Generally there are three types of variables.
•Variable Types
Local Variables, are the variables that are declared inside a
method
Instance Variables, are the variables that are declared outside the
methods
Static Variables, are the variables that are declared outside the
methods with static keyword.
Flow Control Statements
Flow Control Statements
•A statement is an instruction that executes at runtime.
•Types of Statements
1. Sequential Statements
2. Conditional Statements
3. Iterative / Looping Statements
4. Branching Statements
Sequential Statements
Sequential Statements
•These statements execute
sequentially without
interruption one after the
other.
•All the statements we have
executed so far come under
sequential statements.
Conditional Statements
Conditional Statements
•These statements execute
based on a condition’s
success or failure.
•Types :
1. If
2. If-Else
3. Nested If-Else
4. IF-Else Ladder
If Condition
If Condition
•A simple if condition checks
for the condition and will
decide to process the
statements or not.
•Statement 1 and Statement 2
are conditional statements as
they depend on the
condition for executing.
Statement 1;
Statement 2;
If Syntax
if(condition){
statement 1;
statement 2;
statement 3;
}
If-Else Condition
If-Else Condition
•This construct consists of two
statements. (if and else).
•If the condition is success
some statements will get
executed, if failure other
statements will get executed. Statement 1;
Statement 2;
Statement 1;
Statement 2;
If-Else Syntax
if(condition){
statement 1;
statement 2;
}
else{
statement 3;
statement 4;
}
Nested If-Else
Nested If-Else Condition
•If else construct within either
the body of if statement or
the body of an else
statement or both. This
scenario is said to be Nested
If-else
Nested If-Else Syntax
if(condition){
statement 1;
}
else(condition2){
if(condition){
statement 2;
}
else{
statement 3;
}
}
If-Else Ladder
If-Else Ladder
•If-Else ladder is used to check
multiple conditions.
•Here, every else is associated
with it’s previous if.
•The last else will go to work
only if all the conditions fail.
•Even in else if ladder the last
else is optional.
If-Else Ladder Syntax
if(condition){
statement 1;
}
else if(condition){
statement 3;
}
else{
statement 4;
}
Switch-Case Statement
Switch-Case Statement
•Java has a built-in multiple-
branch selection statement,
called switch, which
successively tests the value of
an expression against a list of
integer or character
constants
•When a match is found the
statements associated with
that constant are executed.
Switch-Case Syntax
switch(expression){
case constant1 : Statement1;
break;
case constant2 : Statement2;
break;
case constant3 : Statement3;
break;
default : Statement4;
}
Iterative Statements
Iterative Statements
•Some times there will be a need to
repeat the execution of certain
statements for certain number of times.
•This can be achieved using Loops.
1. While
2. Do-While
3. For
While Loop
While loop
•A while loop has a loop condition only
that is tested before each iteration to
decide whether to continue or
terminate the loop.
•Hence while loop is said to be entry
controlled loop.
While loop Syntax
while(condition){
Statement1;
Statement2;
Statement3;
---
---
---
}
Do-While Loop
Do-While loop
•A do-while loop has a loop condition
only that is tested after each iteration
to decide whether to continue or
terminate the loop.
•Hence, do-while loop is said to be exit
controlled loop.
•Even the condition fails every time the
contents will be executed at least
once.
Do-While Syntax
do{
Statement1;
Statement2;
---
---
---
}while(condition);
For Loop
For loop
• A For loop contains 3 parts.
• Initializer i.e. executed once at the start of
the loop.
• Loop Condition i.e. tested before iteration to
decide whether to continue or terminate the
loop.
• Increment/Decrement i.e. executed at the
end of each loop iteration.
• Hence, for loop is said to be entry controlled
loop.
For Loop Syntax
for(initializer; condition; increment/decrement){
Statement1;
Statement2;
---
---
---
---
}
Foreach Loop
Foreach Loop
•This is an advanced for loop, used to traverse array or
collection elements.
•The advantage of this for loop over traditional is it eliminates
the possibility of bugs and makes the code more readable.
•Syntax:
for( data_type variable : array|collection){}
•The variable will hold on to single value for each iteration
and stores the next value for the next iteration.
Jumping Control Statements
Jumping Control Statements
• Java provides support to some more control statements.
• These statements are used to move the control from one place of a
program to another place.
• These instructions are implemented by using the following statements.
1. Break
2. Continue
3. Go To
Break
• This keyword is used to stop the
loop and go to the statement
following he statement.
• Break can be written with or
without condition.
• Syntax:
break;
Continue
• Continue is a keyword used to skip
iterations.
• When continue is encountered in a loop
the control stops the current iteration i.e. it
will not execute the statements following
it.
• It can also be used with or without
condition.
• Syntax:
continue;
Go TO
• Goto is a specific control statement.
• It is used to jump the control from one part
of the program to other part of the
program.
• It can be used for either as forward or as
backward.
• When forward goto is used the statements
between the goto statement and label
statement will be skipped.
• When backward goto is used the
statements between the goto and label
statements will be repeatedly executed
infinitely if not stopped with a condition.
Important Interview Questions
• What is the most widely used protocol on internet
• What is the difference between an executable file and .class file?
• Why java is suitable for internet?
• Why pointers are eliminated in java?
• What is the difference between a function and a method?
• Which part of the JVM will allocate the memory for java program?
• Which algorithm is used by garbage collector to remove the unused
variables or objects from memory?
Assignments
• Check the hello world program by removing each and every word.
• Shuffle the order of public static void main
• Try experimenting with print & println.
• Try giving different names for args.
• Try giving int args[] instead of String args[] in main.
• Give Different name for the filename and the class name
• Repeat the above problem with declaring class as public
• Copy the class file into different folder name and execute it.
• Write your own program, compile it and execute it.
• Try giving different data types ( the one you know like int x, double d ) in the println
and see if it prints all of them.
• I have two Integers int x =1; and int x=2; I wish to print 12. find the ways to print.
• Repeat the same if I want to print given int x=1; double d=2.5; and print 12 instead of
12.5
Assignments
• Create new classes for each real-world object that you observed at the beginning of
this trail. Refer to the Bicycle class if you forget the required syntax.
• Create a small program that defines some fields. Try creating some illegal field names
and see what kind of error the compiler produces. Use the naming rules and
conventions as a guide.
• In the program you created in Exercise 1, try leaving the fields uninitialized and print
out their values. Try the same with a local variable and see what kind of compiler
errors you can produce. Becoming familiar with common compiler errors will make it
easier to recognize bugs in your code.
Thank You!
Sujit Majety, Technical Head/Software Trainer
SUJIT MAJETY
Technical Head / Corporate Trainer
Techfort Software Solutions PVT. LTD.
Mail To : sujit.majety@gmail.com
Call To : 040-40062299
View Link : http://tinyurl.com/techfort-java1
Feedback : http://tinyurl.com/mrcewfeedback
Ad

More Related Content

What's hot (20)

Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...
Mr. Akaash
 
Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Language
jaimefrozr
 
Core java concepts
Core java  conceptsCore java  concepts
Core java concepts
Ram132
 
Introduction to basics of java
Introduction to basics of javaIntroduction to basics of java
Introduction to basics of java
vinay arora
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
Java Lover
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
Saba Ameer
 
Java Programming
Java ProgrammingJava Programming
Java Programming
Elizabeth alexander
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
Ravi Kant Sahu
 
Introduction to JAVA
Introduction to JAVAIntroduction to JAVA
Introduction to JAVA
ParminderKundu
 
Core java
Core java Core java
Core java
Shubham singh
 
Java basic
Java basicJava basic
Java basic
Sonam Sharma
 
Learn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat ShahriyarLearn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat Shahriyar
Abir Mohammad
 
core java
core javacore java
core java
Roushan Sinha
 
Core java
Core javaCore java
Core java
Shivaraj R
 
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Edureka!
 
Strings in Java
Strings in Java Strings in Java
Strings in Java
Hitesh-Java
 
History Of JAVA
History Of JAVAHistory Of JAVA
History Of JAVA
ARSLANAHMED107
 
Presentation on java
Presentation  on  javaPresentation  on  java
Presentation on java
shashi shekhar
 
Introduction to Java
Introduction to Java Introduction to Java
Introduction to Java
Hitesh-Java
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introduction
jyoti_lakhani
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...
Mr. Akaash
 
Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Language
jaimefrozr
 
Core java concepts
Core java  conceptsCore java  concepts
Core java concepts
Ram132
 
Introduction to basics of java
Introduction to basics of javaIntroduction to basics of java
Introduction to basics of java
vinay arora
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
Java Lover
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
Saba Ameer
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
Ravi Kant Sahu
 
Learn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat ShahriyarLearn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat Shahriyar
Abir Mohammad
 
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Edureka!
 
Strings in Java
Strings in Java Strings in Java
Strings in Java
Hitesh-Java
 
Introduction to Java
Introduction to Java Introduction to Java
Introduction to Java
Hitesh-Java
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introduction
jyoti_lakhani
 

Similar to Introduction to java (revised) (20)

Unit 1 Core Java for Compter Science 3rd
Unit 1 Core Java for Compter Science 3rdUnit 1 Core Java for Compter Science 3rd
Unit 1 Core Java for Compter Science 3rd
prat0ham
 
Assignmentjsnsnshshusjdnsnshhzudjdndndjd
AssignmentjsnsnshshusjdnsnshhzudjdndndjdAssignmentjsnsnshshusjdnsnshhzudjdndndjd
Assignmentjsnsnshshusjdnsnshhzudjdndndjd
tusharjain613841
 
Java Basics.pptx from nit patna ece department
Java Basics.pptx from nit patna ece departmentJava Basics.pptx from nit patna ece department
Java Basics.pptx from nit patna ece department
om2348023vats
 
JAVA PROGRAM CONSTRUCTS OR LANGUAGE BASICS.pptx
JAVA PROGRAM CONSTRUCTS OR LANGUAGE BASICS.pptxJAVA PROGRAM CONSTRUCTS OR LANGUAGE BASICS.pptx
JAVA PROGRAM CONSTRUCTS OR LANGUAGE BASICS.pptx
AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING
 
1 Module 1 Introduction.pptx
1 Module 1 Introduction.pptx1 Module 1 Introduction.pptx
1 Module 1 Introduction.pptx
BhargaviDalal3
 
CS8392 OOP
CS8392 OOPCS8392 OOP
CS8392 OOP
DhanalakshmiVelusamy1
 
oop unit1.pptx
oop unit1.pptxoop unit1.pptx
oop unit1.pptx
sureshkumara29
 
Java Basics
Java BasicsJava Basics
Java Basics
Fahad Shahzad
 
Java UNITbgbgbfdbv v bbfbf cvbgfbvc gf 1.pptx
Java UNITbgbgbfdbv v bbfbf cvbgfbvc gf 1.pptxJava UNITbgbgbfdbv v bbfbf cvbgfbvc gf 1.pptx
Java UNITbgbgbfdbv v bbfbf cvbgfbvc gf 1.pptx
hofon47654
 
Java programming and security
Java programming and securityJava programming and security
Java programming and security
UmeshchandraYadav5
 
java basics concepts and the keywords needed
java basics concepts and the keywords neededjava basics concepts and the keywords needed
java basics concepts and the keywords needed
PriyadharshiniG41
 
Java basic
Java basicJava basic
Java basic
Pooja Thakur
 
Java Programming concept
Java Programming concept Java Programming concept
Java Programming concept
Prakash Poudel
 
Letest
LetestLetest
Letest
Prakash Poudel
 
JAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptxJAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptx
Murugesh33
 
JAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxJAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptx
Murugesh33
 
1. JAVA_Module_1-edited - AJIN ABRAHAM.pptx.pdf
1. JAVA_Module_1-edited - AJIN ABRAHAM.pptx.pdf1. JAVA_Module_1-edited - AJIN ABRAHAM.pptx.pdf
1. JAVA_Module_1-edited - AJIN ABRAHAM.pptx.pdf
10322210023
 
Java
JavaJava
Java
Zeeshan Khan
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
Soumya Suman
 
Java Introduction
Java IntroductionJava Introduction
Java Introduction
sunmitraeducation
 
Unit 1 Core Java for Compter Science 3rd
Unit 1 Core Java for Compter Science 3rdUnit 1 Core Java for Compter Science 3rd
Unit 1 Core Java for Compter Science 3rd
prat0ham
 
Assignmentjsnsnshshusjdnsnshhzudjdndndjd
AssignmentjsnsnshshusjdnsnshhzudjdndndjdAssignmentjsnsnshshusjdnsnshhzudjdndndjd
Assignmentjsnsnshshusjdnsnshhzudjdndndjd
tusharjain613841
 
Java Basics.pptx from nit patna ece department
Java Basics.pptx from nit patna ece departmentJava Basics.pptx from nit patna ece department
Java Basics.pptx from nit patna ece department
om2348023vats
 
1 Module 1 Introduction.pptx
1 Module 1 Introduction.pptx1 Module 1 Introduction.pptx
1 Module 1 Introduction.pptx
BhargaviDalal3
 
Java UNITbgbgbfdbv v bbfbf cvbgfbvc gf 1.pptx
Java UNITbgbgbfdbv v bbfbf cvbgfbvc gf 1.pptxJava UNITbgbgbfdbv v bbfbf cvbgfbvc gf 1.pptx
Java UNITbgbgbfdbv v bbfbf cvbgfbvc gf 1.pptx
hofon47654
 
java basics concepts and the keywords needed
java basics concepts and the keywords neededjava basics concepts and the keywords needed
java basics concepts and the keywords needed
PriyadharshiniG41
 
Java Programming concept
Java Programming concept Java Programming concept
Java Programming concept
Prakash Poudel
 
JAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptxJAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptx
Murugesh33
 
JAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxJAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptx
Murugesh33
 
1. JAVA_Module_1-edited - AJIN ABRAHAM.pptx.pdf
1. JAVA_Module_1-edited - AJIN ABRAHAM.pptx.pdf1. JAVA_Module_1-edited - AJIN ABRAHAM.pptx.pdf
1. JAVA_Module_1-edited - AJIN ABRAHAM.pptx.pdf
10322210023
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
Soumya Suman
 
Ad

Recently uploaded (20)

Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACYUNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
DR.PRISCILLA MARY J
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
Operations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdfOperations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdf
Arab Academy for Science, Technology and Maritime Transport
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
Studying Drama: Definition, types and elements
Studying Drama: Definition, types and elementsStudying Drama: Definition, types and elements
Studying Drama: Definition, types and elements
AbdelFattahAdel2
 
Unit 4: Long term- Capital budgeting and its types
Unit 4: Long term- Capital budgeting and its typesUnit 4: Long term- Capital budgeting and its types
Unit 4: Long term- Capital budgeting and its types
bharath321164
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
Diabetic neuropathy peripheral autonomic
Diabetic neuropathy peripheral autonomicDiabetic neuropathy peripheral autonomic
Diabetic neuropathy peripheral autonomic
Pankaj Patawari
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACYUNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
DR.PRISCILLA MARY J
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
Studying Drama: Definition, types and elements
Studying Drama: Definition, types and elementsStudying Drama: Definition, types and elements
Studying Drama: Definition, types and elements
AbdelFattahAdel2
 
Unit 4: Long term- Capital budgeting and its types
Unit 4: Long term- Capital budgeting and its typesUnit 4: Long term- Capital budgeting and its types
Unit 4: Long term- Capital budgeting and its types
bharath321164
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
Diabetic neuropathy peripheral autonomic
Diabetic neuropathy peripheral autonomicDiabetic neuropathy peripheral autonomic
Diabetic neuropathy peripheral autonomic
Pankaj Patawari
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
Ad

Introduction to java (revised)

  • 1. Hello Everyone! Welcome to TECHFORT’s Training
  • 4. • Introduction • Programming Paradigm • History • Features • Sample Program • Execution Steps • JVM • Data types • Objects and Classes • Variables • Flow Control Statements Java Introduction Day 1 : Agenda
  • 5. Introduction Lets start our exiting journey from now.
  • 6. Introduction •Java is one of the most powerful programming languages. •Java is cross-platform, object-oriented, network-based, reliable programming language. •The slogan of java is “write once and run anywhere”, this allowed java to gain enormous popularity. Its rapid ascension and wide acceptance can be traced to its design and programming features. •The name “JAVA” came from the name of the coffee seed. •JAVA released to market in different platforms.
  • 7. Java Platforms •A java platform or edition consists of a JRE with a specific set of libraries for a specific application environment. PLATFORM KEY CHARACTERISTICS J2SE Core Java platform designed for applications running on desktop PCs. J2EE Design, development, assembly, and deployment of business Applications. J2ME Design of small, embedded applications in consumer devices (such as mobile phones). Java Card Design of small Java applications that run on smart cards. JavaFX Design of Rich Internet Applications (RIAs).
  • 8. Programming Paradigm A way of conceptualizing what it means to perform computation
  • 9. Programming Paradigms Procedure Oriented • More emphasis on algorithms. • Programs divided into functions. • Most functions share data, less security to data. • Data move around the system between functions, any function can change the data. • Adding new code is very difficult. • Code cannot be re-used. • E.g. C, VB, Perl, Basic, Fortran Object Oriented •More emphasis on data. •Programs are divided into objects. •Functions operate on data are tied together in the data structure. •Data is secured; it is hidden to external functions, can be accessed by functions tied to it. •Adding new code is very easy. •Code can be re-used. •E.g. CPP, Java, VB.Net, C#.Net
  • 11. History •Developed by a team led by James Gosling at Sun Microsystems. •Sun Microsystems was a company best known for its workstations. •Java was originally OAK, designed for use in embedded consumer electronic application in 1991. •OAK was redesigned for developing internet applications and renamed JAVA in 1995. •Java is inherently object-oriented.
  • 12. History Major Release Date Key Characteristics JDK 1.0 1996 First stable version of Java JDK 1.1 1997 Inner classes; Java beans; JDBC; RMI; Just in Time (JIT) compiler for Windows platforms JDK 1.2 1998 Swing classes; Java IDL; Collections JDK 1.3 2000 Java platform debugger architecture (JPDA); JavaSound; HotSpot JVM JDK 1.4 2002 Regular expressions; IPv6 support; image I/O API; non-blocking I/O (nio); XML parser and XSLT processor JDK 5.0 2004 Generics; annotations; autoboxing; enumerations; varargs; for each loop JAVA SE 6 2006 Improved GUI support; improved web service support JAVA SE 7 2011 New file I/O capabilities; support for new network protocols JAVA SE 8 2014 Lambda expressions; new date and time API JAVA SE 9 2016 (expected) Money and currency API
  • 14. Features There are eleven promising features in java • Simple (no pointers, interfaces, rich set of API, friendly syntaxes) • Secure (many number of security mechanisms to block stray programs) • Portable (can run on any operating system) • Robust (memory management, exceptional handling) • Distributed (runs on multiple servers and can be accessed by no of clients) • Interpreted (both compiled and interpreted) • Multi Threading (multiple flow of controls) • Dynamic (is always open for updating) • Architecture Neutral (can run on any processor) • High Performance (garbage collector, leaves resources wile waiting for inputs) • Object oriented (everything is written in class)
  • 15. Our First Java Program
  • 16. First Java Program public class Test { public static void main(String[] args) { System.out.println("HELLO WORLD"); } } javac Test.java Java Test HELLO WORLD
  • 18. Execution Steps Text editor Java Virtual Machine Java Compiler Source Code (.java) Byte code (.class) Output on Console Saves Java statements Produces Result in
  • 19. JVM
  • 20. JVM •JVM stands for Java Virtual Machine. •It is abstract machine. •It is a specification that provides runtime environment in which java byte code can be executed. •JVM’s are available for many hardware and software platforms (i.e. JVM is platform dependant). •JVM performs four main tasks, Loads code Verifies code Executes code Provides runtime environment.
  • 23. Data Types • Java supports UNICODE character set. Hence, each character is represented in two bytes. • In java every variable has a type, every expression has a type and all assignments should be checked by the compiler for type compatibility. Hence, java is treated as strongly typed language. • We are having 8 primitive data types. • These data types fall under 3 categories. • Numeric Data types • Character Data types • Boolean Data types
  • 24. Data Types DATA TYPE SIZE RANGE DEFAULT VALUE byte 8 bit -128 to 127 0 short 16 bit -32768 to 32767 0 int 32 bit -2,147,483,648 to 2,147,483, 647 0 long 64 bit -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 0L float 32 bit approximately ±3.40282347E+38F 0.0f double 64 bit approximately ±1.79769313486231570E+308 0.0d char 16 bit 0 to 65,536 (unsigned) ‘u0000’ boolean not precisely defined true or false false
  • 26. OOP • Object oriented programming models the real world. • Object oriented programming organizes a program around its data and set of well defined interfaces to that data. • An object-oriented program can be characterized as data controlling access to code. • By switching the controlling entity to data, you can achieve several organizational benefits. • Object oriented programming, the first letter indicates object. • What is an object?
  • 27. Object •An object is the basic unit of object orientation with behaviour and identity. •An object is a real time entity. E.g.. Car, bike, book, me and you. •It is a runtime entity that has a state and behaviour. •The state of the object represents the data. •The behaviour is represented by the methods. •E.g. An object is created to represent a rabbit. It would have data: how hungry it is, where it is. And methods : eat, hide, run and dig.
  • 28. Class • A class is a way of binding the data and associated methods into a single unit. • A class can also be said as a blue print to create an object. • If we want to develop a java program, then that should be developed with respective of class only. i.e. without class there is no java program. • Syntax: class <class_name> { Variable declaration; Methods definition; }; Class Name Data members/ properties/ Attributes Behaviours/ Methods Animal Name, Number of legs, Colour Eat(), Walk(), Sleep()
  • 29. Example class Bicycle { int cadence = 0; int speed = 0; int gear = 1; void changeCadence(int newValue) { cadence = newValue; } void changeGear(int newValue) { gear = newValue; } void speedUp(int increment) { speed = speed + increment; } void applyBrakes(int decrement) { speed = speed - decrement; } void printStates() { System.out.println("cadence:" + cadence + " speed:" + speed + " gear:" + gear); } }
  • 31. Variables •A variable is a name given to a memory location. •Generally there are three types of variables. •Variable Types Local Variables, are the variables that are declared inside a method Instance Variables, are the variables that are declared outside the methods Static Variables, are the variables that are declared outside the methods with static keyword.
  • 33. Flow Control Statements •A statement is an instruction that executes at runtime. •Types of Statements 1. Sequential Statements 2. Conditional Statements 3. Iterative / Looping Statements 4. Branching Statements
  • 35. Sequential Statements •These statements execute sequentially without interruption one after the other. •All the statements we have executed so far come under sequential statements.
  • 37. Conditional Statements •These statements execute based on a condition’s success or failure. •Types : 1. If 2. If-Else 3. Nested If-Else 4. IF-Else Ladder
  • 39. If Condition •A simple if condition checks for the condition and will decide to process the statements or not. •Statement 1 and Statement 2 are conditional statements as they depend on the condition for executing. Statement 1; Statement 2;
  • 42. If-Else Condition •This construct consists of two statements. (if and else). •If the condition is success some statements will get executed, if failure other statements will get executed. Statement 1; Statement 2; Statement 1; Statement 2;
  • 43. If-Else Syntax if(condition){ statement 1; statement 2; } else{ statement 3; statement 4; }
  • 45. Nested If-Else Condition •If else construct within either the body of if statement or the body of an else statement or both. This scenario is said to be Nested If-else
  • 46. Nested If-Else Syntax if(condition){ statement 1; } else(condition2){ if(condition){ statement 2; } else{ statement 3; } }
  • 48. If-Else Ladder •If-Else ladder is used to check multiple conditions. •Here, every else is associated with it’s previous if. •The last else will go to work only if all the conditions fail. •Even in else if ladder the last else is optional.
  • 49. If-Else Ladder Syntax if(condition){ statement 1; } else if(condition){ statement 3; } else{ statement 4; }
  • 51. Switch-Case Statement •Java has a built-in multiple- branch selection statement, called switch, which successively tests the value of an expression against a list of integer or character constants •When a match is found the statements associated with that constant are executed.
  • 52. Switch-Case Syntax switch(expression){ case constant1 : Statement1; break; case constant2 : Statement2; break; case constant3 : Statement3; break; default : Statement4; }
  • 54. Iterative Statements •Some times there will be a need to repeat the execution of certain statements for certain number of times. •This can be achieved using Loops. 1. While 2. Do-While 3. For
  • 56. While loop •A while loop has a loop condition only that is tested before each iteration to decide whether to continue or terminate the loop. •Hence while loop is said to be entry controlled loop.
  • 59. Do-While loop •A do-while loop has a loop condition only that is tested after each iteration to decide whether to continue or terminate the loop. •Hence, do-while loop is said to be exit controlled loop. •Even the condition fails every time the contents will be executed at least once.
  • 62. For loop • A For loop contains 3 parts. • Initializer i.e. executed once at the start of the loop. • Loop Condition i.e. tested before iteration to decide whether to continue or terminate the loop. • Increment/Decrement i.e. executed at the end of each loop iteration. • Hence, for loop is said to be entry controlled loop.
  • 63. For Loop Syntax for(initializer; condition; increment/decrement){ Statement1; Statement2; --- --- --- --- }
  • 65. Foreach Loop •This is an advanced for loop, used to traverse array or collection elements. •The advantage of this for loop over traditional is it eliminates the possibility of bugs and makes the code more readable. •Syntax: for( data_type variable : array|collection){} •The variable will hold on to single value for each iteration and stores the next value for the next iteration.
  • 67. Jumping Control Statements • Java provides support to some more control statements. • These statements are used to move the control from one place of a program to another place. • These instructions are implemented by using the following statements. 1. Break 2. Continue 3. Go To
  • 68. Break • This keyword is used to stop the loop and go to the statement following he statement. • Break can be written with or without condition. • Syntax: break;
  • 69. Continue • Continue is a keyword used to skip iterations. • When continue is encountered in a loop the control stops the current iteration i.e. it will not execute the statements following it. • It can also be used with or without condition. • Syntax: continue;
  • 70. Go TO • Goto is a specific control statement. • It is used to jump the control from one part of the program to other part of the program. • It can be used for either as forward or as backward. • When forward goto is used the statements between the goto statement and label statement will be skipped. • When backward goto is used the statements between the goto and label statements will be repeatedly executed infinitely if not stopped with a condition.
  • 71. Important Interview Questions • What is the most widely used protocol on internet • What is the difference between an executable file and .class file? • Why java is suitable for internet? • Why pointers are eliminated in java? • What is the difference between a function and a method? • Which part of the JVM will allocate the memory for java program? • Which algorithm is used by garbage collector to remove the unused variables or objects from memory?
  • 72. Assignments • Check the hello world program by removing each and every word. • Shuffle the order of public static void main • Try experimenting with print & println. • Try giving different names for args. • Try giving int args[] instead of String args[] in main. • Give Different name for the filename and the class name • Repeat the above problem with declaring class as public • Copy the class file into different folder name and execute it. • Write your own program, compile it and execute it. • Try giving different data types ( the one you know like int x, double d ) in the println and see if it prints all of them. • I have two Integers int x =1; and int x=2; I wish to print 12. find the ways to print. • Repeat the same if I want to print given int x=1; double d=2.5; and print 12 instead of 12.5
  • 73. Assignments • Create new classes for each real-world object that you observed at the beginning of this trail. Refer to the Bicycle class if you forget the required syntax. • Create a small program that defines some fields. Try creating some illegal field names and see what kind of error the compiler produces. Use the naming rules and conventions as a guide. • In the program you created in Exercise 1, try leaving the fields uninitialized and print out their values. Try the same with a local variable and see what kind of compiler errors you can produce. Becoming familiar with common compiler errors will make it easier to recognize bugs in your code.
  • 74. Thank You! Sujit Majety, Technical Head/Software Trainer
  • 75. SUJIT MAJETY Technical Head / Corporate Trainer Techfort Software Solutions PVT. LTD. Mail To : [email protected] Call To : 040-40062299 View Link : http://tinyurl.com/techfort-java1 Feedback : http://tinyurl.com/mrcewfeedback