SlideShare a Scribd company logo
1
Mr. Akaash
akaashhakim@gmail.com
Java: Introduction Basic
Structure, variables Data type,
input & output
2
Why Java is developed.
 Sun Microsystems ins. Develop deferent software for deferent
devices. Even the work of these soft wares is same.
 If they want to run this software on others platform that is not
possible. then They must have to write deferent program. They write
this program in c/C++.
 Then they release that we reduce this effort only if they Develop a
platform independent language. (Means: Program is written on a
platform then it execute on any platform)
 What is platform? Platform is a environment in that the software is
executed. For we example. In our computer the software is only run
because in our computers one software is already executed. This
software is Operating system.
3
Why Java is developed.
 Operating system works as a platform for those programs that we
want to execute.
 Without operating system we can't run any program
 If any program is execute of deferent operating system then we
call it platform independent software
 For this purpose Sun Microsystems Inc. want to develop a java
language
 In earlier java is developed as a solution of an problem.
4
Introduction of JAVA
 Originally created for consumer
electronics (TV, VCR, Freeze, Washing
Machine, Mobile Phone).
 Java - CPU Independent language
 Internet and Web was just emerging, so
Sun turned it into a language of Internet
Programming.
 It allows you to publish a webpage with
Java code in it.
5
History of Java
 Java Language is developed in 1991 in the form of a project.
 Java Programming Language was written by James Gosling along
with two other person 'Mike Sheridan' and 'Patrick Naughton',
while they were working at Sun Microsystems Inc.
 In earlier Sum Microsystems Inc. want to register this language with the
name OAK language. OAK is the name of tree which is placed out side
the office of James Gosling
 Later the project went by the name Green and was finally renamed
Java, from Java coffee
Java developer James Gosling
6
History of Java
 Java was originally designed for interactive television,
but it was too advanced for the digital cable television
industry at the time
 Gosling designed Java with a C/C++-style syntax that
system and application programmers would find familiar
7
History of java
 On January 27, 2010. java Sun
Microsystems Inc. acquired by Oracle
corporation for US$ 7.4 Billon.
8
Java is everywhere
 JAVA resides in mobiles, client machines,
server machines, embedded devices, smart
phones, cloud etc.
 It Shares same basic features of the language
and libraries
 Principle of JAVA: WORA (Write Once, Run
Anywhere)
9
What is Library
 What is library in C/C++?
 We can say that in C/C++ collection of predefined function is
called C Library
 Java Library is a collection of predefined classes. Like a C/C++.
10
Version history of JAVA
11
There were nine primary goals in the
creation of the Java language:

Simple

Object Oriented Programming

Distributed

Interpreted

Robust

Secure
12
Explanation of Feature of JAVA
 Object-Oriented Programming
 Object-oriented programming (OOP) is a programming
language model organized around objects rather than
"actions" and data rather than logic. Historically, a program
has been viewed as a logical procedure that takes input data,
processes it, and produces output data
 Distributed
 Distributed Java Programming with RMI and CORBA. ...
The Java Remote Method Invocation (RMI) mechanism and
the Common Object Request Broker Architecture (CORBA) are
the two most important and widely used distributed object
systems. Each system has its own features and shortcomings.
13
Explanation of Feature of JAVA
 Interpreted
 Java is a compiled programming language, but rather than
compile straight to executable machine code, it compiles to an
intermediate binary form called JVM byte code. The byte
code is then compiled and/or interpreted to run the program.
 Robust
 Java is Robust because it is highly supported language. It is
portable across many Operating systems. Java also has
feature of Automatic memory management and garbage
collection. Strong type checking mechanism of Java also helps
in making Java Robust. Bugs, especially system crashing
bugs, are very rare in Java
14
Explanation of Feature of JAVA
 Secure
 Vulnerabilities in the protection mechanisms provided by the
hardware or operating system which the application relies upon
for its security. Vulnerabilities in native libraries, such as the C
standard library, which may be used to implement the
application and/or runtime
 Portable
 "Java is portable" refers to the SE version. It means that you
can run Java byte code on any hardware that has a compliant
JVM. It doesn't mean that ME is the same as SE is the same
as EE.
15
Explanation of Feature of JAVA
 Multithreaded
 The main purpose of multithreading is to provide
simultaneous execution of two or more parts of a program to
maximum utilize the CPU time. A multithreaded program
contains two or more parts that can run concurrently. ...
RUNNABLE – A thread executing in the Java virtual machine
is in this state.
 Garbage collector
 The garbage collector is a program which runs on the Java
Virtual Machine which gets rid of objects which are not being
used by a Java application anymore. It is a form of automatic
memory management
16
How to Compile Java Program
When we compile
.Java file it create
.class file
C/C++ compilers convert C/C++ code
in these language which Operating
System Understand… But the JAVA
Compiler convert JAVA code into
Byte code. Operating System can’t
understand this code.
If .java file has 5 classes then JAVA
compiler create five deferent class
files.…
17
Practical of Compile java program
 Firstly we write our java
program in notepad
 Then save this code with
.java extension in bin folder
This bin folderThis bin folder
Saving hello program
with .java extension
Saving hello program
with .java extension
18
Before compile Java program
there is no .class file created
Before compile Java program
there is no .class file created
javac is java compiler
that convert java code to
byte code
javac is java compiler
that convert java code to
byte code
It is java codeIt is java code
After compile
the java code
java compiler
create .class file
After compile
the java code
java compiler
create .class file
19
How Run JAVA Program
For run java program: We install JVM(JAVA Virtual
Machine) we can run our Byte code file with the help
of JVM
JVM is the
Operating System
dependent
program.
This is JVM that execute the
This is .class file
we don’t have to
need write its
extension
Output
20
Java is Compiled and Interpreted
Text Editor Compiler Interpreter
Programmer
Source Code
.java file
Byte Code
.class file
Hardware and
Operating System
Notepad etc. javac java
appletviewer
netscape
21
JAVA Virtual Machine
 JVM is the platform dependent
 The JAVA Virtual Machine provides the
platform-independent way to execute JAVA
code .
 Java Virtual Machine interprets the byte code into
the machine code depending upon the underlying
operating system and hardware combination
22
Total Platform Independence
JAVA COMPILERJAVA COMPILER
JAVA BYTE CODEJAVA BYTE CODE
JAVA INTERPRETERJAVA INTERPRETER
Windows 95 Macintosh Solaris Windows NT
(translator)
(same for all platforms)
(one for each different system)
23
JAVA
 Java is case sensitive language like C/C+
+.
 Java is nearly 100% Object-oriented
language.
 In java it is not possible to make a
function which is not member of any class
(as we do C/C++)
24
NO , Java is 99% oop .
Remaining 1% ?????????
Java 100% OOP???
Reason Primitive Data Types
25
Primitive Data Types Wrapper Classes
1.byte Byte
2.int Integer
3.short Short
4.long Long
5.float Float
6.double Double
7.char Character
8.boolean Boolean
Data Type & Wrapper classes
26
Java Applications
 We can develop two types of Java
programs:
 Stand-alone applications
 Web applications (applets)
27
Java better than C++ ?
 No Typedefs, Defines, or Preprocessor
 No Global Variables
 No Goto statements
 No Pointers
 No Unsafe Structures
 No Multiple Inheritance
 No Operator Overloading
 No Automatic Coercions
 No Fragile Data Types
?
28
Object Oriented Languages -A
Comparison
Feature C++ Objective
C
Ada Java
Encapsulation Yes Yes Yes Yes
Inheritance Yes Yes No Yes
Multiple Inherit. Yes Yes No No
Polymorphism Yes Yes Yes Yes
Binding (Early or Late) Both Both Early Late
Concurrency Poor Poor Difficult Yes
Garbage Collection No Yes No Yes
Genericity Yes No Yes Limited
Class Libraries Yes Yes Limited Yes
29
Basic Structure that almost use in
every java program
Wrapper Class
Main MethodMain Method
Class NameClass Name
Package Name
Body of Main methodBody of Main method
Java Application Save with class name
and .java extension
Java Application Save with class name
and .java extension
Public keyword
specified that main()
function accessible
outside the class
The void specifies means that
main() does not return any
values
Static keyword specified
that main() exists without
any object be defined
The outer class may a public
or default
The inner class may a public
private, protected or default
30
Short Detail of previous Image
 Package:-
 A package have many classes Same type of classes are store in same package.
 Public:-
 The Public keyword specified that main() function accessible outside the class
 Class Name:-
 Class name is user define.
 Class:-
 is Keyword that is optional.
 Static:-
 The Static keyword specified that main() exists without any object be defined
 Void main:-
 Main Method
 String[]:-
 Wrapper Class
 Arg:-
 Arguments
31
Variable in Java
 Variable is used to access data .
 We use variable to store data.
 Variable use for get input from
user.
 Variable used for give output to
user.
32
Variable Declaration
 We declare a variable in java same as in C++.
 Syntax:
Data_type variable_name;
 DataTypes:
 Data_types used for defined type of variable for example you
store (10) integer data. We use int data type.
 Varible_name:
 Variable name is user defined. we can declare variable name
following variable declaration rules
33
Data Types
 Data Types that define which type of value used in program
 There are many data types of java
 Integer Data types
Declaration of integer Variable
Data_types Variablename;
34
Data types
 Floating Data types
Declaration of Floating Variable
Data_types Variablename;
35
Java Output
We use “System.out.println()” for print any
message or result on screen.
System.out.println(“ “)
This is the name of
class that contains
the object out
This is the name of
class that contains
the object out
This is a static
variable that in
system class
This is a static
variable that in
system class
This a method in
object out
Whatever you specify between parenthesis () is
passed to the println( ) method and displayed
36
System.out.println();
System.out.println();
It is used to display message, result and Message+Result.
System is a class that is in java.lang package.
Java.lang package by default import in netbean IDE.
In println() method, “ln” use for new line.
37
System.out.println()
 It used for 3 purpose “Message” , ”Result” and “Message + result”
System.out.println();
Message Result Message + Result
38
System.out.println()/print();
Message
Write Message in Double Quotes(” ”).
Message Display as it we Write in Double Quotes.
39
System.out.println()/print();
Result
Write Result in without Double Quotes(” ”).
What is 15?
Sum of two numbers? OR
Product of two numbers?
40
System.out.println()/print();
Message+Result
Write Message in Double Quotes(” ”).
Write Result in without Double Quotes(” ”).
For concatenation Message and result use plus(+) operator.
Message Result OutputConcate..
.
41
System.out.println()/print();
Message Result OutPutConcate..
.
42
Input in Java
 For input in java
 We import a scanner
 We create a scanner object
 We use methods.
Firstly import Scanner
Create object
Use methods
It is class name
Object name it is user defined
It is Constructer
For Integer Number
More
function
43
More input methods
44
Input program
Output
45
Code of previous Image
package javaapplication6;
import java.util.*;
public class JavaApplication6 {
public static void main(String[] args) {
Scanner obj=new Scanner(System.in);
int num1,num2;
System.out.print("Enter first integer number ::");
num1=obj.nextInt();
System.out.print("Enter Second integer number ::");
num2=obj.nextInt();
System.out.println(num1+"+"+num2+"="+(num1+num2));
}
}

More Related Content

PPT
Core java slides
Abhilash Nair
 
PDF
Introduction to java (revised)
Sujit Majety
 
PPTX
Introduction to java
Java Lover
 
PPTX
Core java
Ravi varma
 
PPTX
Java Programming
Elizabeth alexander
 
PDF
Introduction to Java Programming Language
jaimefrozr
 
PDF
Basic Java Programming
Math-Circle
 
PDF
Genesis and Overview of Java
Ravi_Kant_Sahu
 
Core java slides
Abhilash Nair
 
Introduction to java (revised)
Sujit Majety
 
Introduction to java
Java Lover
 
Core java
Ravi varma
 
Java Programming
Elizabeth alexander
 
Introduction to Java Programming Language
jaimefrozr
 
Basic Java Programming
Math-Circle
 
Genesis and Overview of Java
Ravi_Kant_Sahu
 

What's hot (20)

PDF
Applets
Prabhakaran V M
 
PPTX
JRE , JDK and platform independent nature of JAVA
Mehak Tawakley
 
PPTX
Event Handling in java
Google
 
PPTX
Introduction to java
Saba Ameer
 
PPTX
Core java
Shivaraj R
 
PPTX
[Final] ReactJS presentation
洪 鹏发
 
DOCX
JDK,JRE,JVM
Cognizant
 
PPTX
Introduction to java
Sandeep Rawat
 
PDF
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Edureka!
 
PPTX
core java
Roushan Sinha
 
PPTX
Spring boot - an introduction
Jonathan Holloway
 
PPTX
Core Java Tutorials by Mahika Tutorials
Mahika Tutorials
 
PPTX
Spring boot
Gyanendra Yadav
 
PDF
JavaScript - Chapter 13 - Browser Object Model(BOM)
WebStackAcademy
 
PPT
9. Input Output in java
Nilesh Dalvi
 
PDF
Introduction to Java Programming
Ravi Kant Sahu
 
PPSX
Arrays in Java
Hitesh-Java
 
PPTX
Apache tomcat
Shashwat Shriparv
 
PPT
Java multi threading
Raja Sekhar
 
PPTX
Introduction to JAVA
ParminderKundu
 
JRE , JDK and platform independent nature of JAVA
Mehak Tawakley
 
Event Handling in java
Google
 
Introduction to java
Saba Ameer
 
Core java
Shivaraj R
 
[Final] ReactJS presentation
洪 鹏发
 
JDK,JRE,JVM
Cognizant
 
Introduction to java
Sandeep Rawat
 
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Edureka!
 
core java
Roushan Sinha
 
Spring boot - an introduction
Jonathan Holloway
 
Core Java Tutorials by Mahika Tutorials
Mahika Tutorials
 
Spring boot
Gyanendra Yadav
 
JavaScript - Chapter 13 - Browser Object Model(BOM)
WebStackAcademy
 
9. Input Output in java
Nilesh Dalvi
 
Introduction to Java Programming
Ravi Kant Sahu
 
Arrays in Java
Hitesh-Java
 
Apache tomcat
Shashwat Shriparv
 
Java multi threading
Raja Sekhar
 
Introduction to JAVA
ParminderKundu
 
Ad

Similar to Introduction to Java Programming, Basic Structure, variables Data type, input & output (20)

PPTX
UNIT 1 Programming in java Bsc program.pptx
jijinamt
 
DOCX
java introduction.docx
vikasbagra9887
 
PPTX
What is Java, JDK, JVM, Introduction to Java.pptx
kumarsuneel3997
 
PPTX
UNIT 1.pptx
EduclentMegasoftel
 
PPT
Java ppt-class_Introduction_class_Objects.ppt
VGaneshKarthikeyan
 
PPTX
Java
seenak
 
DOCX
Srgoc java
Gaurav Singh
 
PPT
Java-Unit-I.ppt
RameswarGprec
 
PPTX
Object Oriented Programming Part 1 of Unit 1
VigneshkumarPonnusam1
 
PPTX
Chapter-1 Introduction.pptx
SumanBhandari40
 
PPT
Java2020 programming basics and fundamentals
swecsaleem
 
PPT
Java ppt-class_basic data types methods definitions
ganeshkarthy
 
PPTX
Unit1 JAVA.pptx
RahulAnand111531
 
PPTX
JAVA PROGRAM CONSTRUCTS OR LANGUAGE BASICS.pptx
AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING
 
PPTX
Chapter 1 (1).pptx
krishnashah277578
 
PPTX
Java
Snehal Shahane
 
PDF
Java programming material for beginners by Nithin, VVCE, Mysuru
Nithin Kumar,VVCE, Mysuru
 
UNIT 1 Programming in java Bsc program.pptx
jijinamt
 
java introduction.docx
vikasbagra9887
 
What is Java, JDK, JVM, Introduction to Java.pptx
kumarsuneel3997
 
UNIT 1.pptx
EduclentMegasoftel
 
Java ppt-class_Introduction_class_Objects.ppt
VGaneshKarthikeyan
 
Java
seenak
 
Srgoc java
Gaurav Singh
 
Java-Unit-I.ppt
RameswarGprec
 
Object Oriented Programming Part 1 of Unit 1
VigneshkumarPonnusam1
 
Chapter-1 Introduction.pptx
SumanBhandari40
 
Java2020 programming basics and fundamentals
swecsaleem
 
Java ppt-class_basic data types methods definitions
ganeshkarthy
 
Unit1 JAVA.pptx
RahulAnand111531
 
JAVA PROGRAM CONSTRUCTS OR LANGUAGE BASICS.pptx
AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING
 
Chapter 1 (1).pptx
krishnashah277578
 
Java programming material for beginners by Nithin, VVCE, Mysuru
Nithin Kumar,VVCE, Mysuru
 
Ad

Recently uploaded (20)

PPTX
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
PPTX
CDH. pptx
AneetaSharma15
 
PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
DOCX
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
PPTX
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
PDF
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
AshifaRamadhani
 
PDF
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
PDF
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
PDF
Health-The-Ultimate-Treasure (1).pdf/8th class science curiosity /samyans edu...
Sandeep Swamy
 
PDF
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
PDF
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
PPTX
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
PDF
RA 12028_ARAL_Orientation_Day-2-Sessions_v2.pdf
Seven De Los Reyes
 
PPT
Python Programming Unit II Control Statements.ppt
CUO VEERANAN VEERANAN
 
PPTX
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
PPTX
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
CDH. pptx
AneetaSharma15
 
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
AshifaRamadhani
 
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
Health-The-Ultimate-Treasure (1).pdf/8th class science curiosity /samyans edu...
Sandeep Swamy
 
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
RA 12028_ARAL_Orientation_Day-2-Sessions_v2.pdf
Seven De Los Reyes
 
Python Programming Unit II Control Statements.ppt
CUO VEERANAN VEERANAN
 
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 

Introduction to Java Programming, Basic Structure, variables Data type, input & output

  • 1. 1 Mr. Akaash [email protected] Java: Introduction Basic Structure, variables Data type, input & output
  • 2. 2 Why Java is developed.  Sun Microsystems ins. Develop deferent software for deferent devices. Even the work of these soft wares is same.  If they want to run this software on others platform that is not possible. then They must have to write deferent program. They write this program in c/C++.  Then they release that we reduce this effort only if they Develop a platform independent language. (Means: Program is written on a platform then it execute on any platform)  What is platform? Platform is a environment in that the software is executed. For we example. In our computer the software is only run because in our computers one software is already executed. This software is Operating system.
  • 3. 3 Why Java is developed.  Operating system works as a platform for those programs that we want to execute.  Without operating system we can't run any program  If any program is execute of deferent operating system then we call it platform independent software  For this purpose Sun Microsystems Inc. want to develop a java language  In earlier java is developed as a solution of an problem.
  • 4. 4 Introduction of JAVA  Originally created for consumer electronics (TV, VCR, Freeze, Washing Machine, Mobile Phone).  Java - CPU Independent language  Internet and Web was just emerging, so Sun turned it into a language of Internet Programming.  It allows you to publish a webpage with Java code in it.
  • 5. 5 History of Java  Java Language is developed in 1991 in the form of a project.  Java Programming Language was written by James Gosling along with two other person 'Mike Sheridan' and 'Patrick Naughton', while they were working at Sun Microsystems Inc.  In earlier Sum Microsystems Inc. want to register this language with the name OAK language. OAK is the name of tree which is placed out side the office of James Gosling  Later the project went by the name Green and was finally renamed Java, from Java coffee Java developer James Gosling
  • 6. 6 History of Java  Java was originally designed for interactive television, but it was too advanced for the digital cable television industry at the time  Gosling designed Java with a C/C++-style syntax that system and application programmers would find familiar
  • 7. 7 History of java  On January 27, 2010. java Sun Microsystems Inc. acquired by Oracle corporation for US$ 7.4 Billon.
  • 8. 8 Java is everywhere  JAVA resides in mobiles, client machines, server machines, embedded devices, smart phones, cloud etc.  It Shares same basic features of the language and libraries  Principle of JAVA: WORA (Write Once, Run Anywhere)
  • 9. 9 What is Library  What is library in C/C++?  We can say that in C/C++ collection of predefined function is called C Library  Java Library is a collection of predefined classes. Like a C/C++.
  • 11. 11 There were nine primary goals in the creation of the Java language:  Simple  Object Oriented Programming  Distributed  Interpreted  Robust  Secure
  • 12. 12 Explanation of Feature of JAVA  Object-Oriented Programming  Object-oriented programming (OOP) is a programming language model organized around objects rather than "actions" and data rather than logic. Historically, a program has been viewed as a logical procedure that takes input data, processes it, and produces output data  Distributed  Distributed Java Programming with RMI and CORBA. ... The Java Remote Method Invocation (RMI) mechanism and the Common Object Request Broker Architecture (CORBA) are the two most important and widely used distributed object systems. Each system has its own features and shortcomings.
  • 13. 13 Explanation of Feature of JAVA  Interpreted  Java is a compiled programming language, but rather than compile straight to executable machine code, it compiles to an intermediate binary form called JVM byte code. The byte code is then compiled and/or interpreted to run the program.  Robust  Java is Robust because it is highly supported language. It is portable across many Operating systems. Java also has feature of Automatic memory management and garbage collection. Strong type checking mechanism of Java also helps in making Java Robust. Bugs, especially system crashing bugs, are very rare in Java
  • 14. 14 Explanation of Feature of JAVA  Secure  Vulnerabilities in the protection mechanisms provided by the hardware or operating system which the application relies upon for its security. Vulnerabilities in native libraries, such as the C standard library, which may be used to implement the application and/or runtime  Portable  "Java is portable" refers to the SE version. It means that you can run Java byte code on any hardware that has a compliant JVM. It doesn't mean that ME is the same as SE is the same as EE.
  • 15. 15 Explanation of Feature of JAVA  Multithreaded  The main purpose of multithreading is to provide simultaneous execution of two or more parts of a program to maximum utilize the CPU time. A multithreaded program contains two or more parts that can run concurrently. ... RUNNABLE – A thread executing in the Java virtual machine is in this state.  Garbage collector  The garbage collector is a program which runs on the Java Virtual Machine which gets rid of objects which are not being used by a Java application anymore. It is a form of automatic memory management
  • 16. 16 How to Compile Java Program When we compile .Java file it create .class file C/C++ compilers convert C/C++ code in these language which Operating System Understand… But the JAVA Compiler convert JAVA code into Byte code. Operating System can’t understand this code. If .java file has 5 classes then JAVA compiler create five deferent class files.…
  • 17. 17 Practical of Compile java program  Firstly we write our java program in notepad  Then save this code with .java extension in bin folder This bin folderThis bin folder Saving hello program with .java extension Saving hello program with .java extension
  • 18. 18 Before compile Java program there is no .class file created Before compile Java program there is no .class file created javac is java compiler that convert java code to byte code javac is java compiler that convert java code to byte code It is java codeIt is java code After compile the java code java compiler create .class file After compile the java code java compiler create .class file
  • 19. 19 How Run JAVA Program For run java program: We install JVM(JAVA Virtual Machine) we can run our Byte code file with the help of JVM JVM is the Operating System dependent program. This is JVM that execute the This is .class file we don’t have to need write its extension Output
  • 20. 20 Java is Compiled and Interpreted Text Editor Compiler Interpreter Programmer Source Code .java file Byte Code .class file Hardware and Operating System Notepad etc. javac java appletviewer netscape
  • 21. 21 JAVA Virtual Machine  JVM is the platform dependent  The JAVA Virtual Machine provides the platform-independent way to execute JAVA code .  Java Virtual Machine interprets the byte code into the machine code depending upon the underlying operating system and hardware combination
  • 22. 22 Total Platform Independence JAVA COMPILERJAVA COMPILER JAVA BYTE CODEJAVA BYTE CODE JAVA INTERPRETERJAVA INTERPRETER Windows 95 Macintosh Solaris Windows NT (translator) (same for all platforms) (one for each different system)
  • 23. 23 JAVA  Java is case sensitive language like C/C+ +.  Java is nearly 100% Object-oriented language.  In java it is not possible to make a function which is not member of any class (as we do C/C++)
  • 24. 24 NO , Java is 99% oop . Remaining 1% ????????? Java 100% OOP??? Reason Primitive Data Types
  • 25. 25 Primitive Data Types Wrapper Classes 1.byte Byte 2.int Integer 3.short Short 4.long Long 5.float Float 6.double Double 7.char Character 8.boolean Boolean Data Type & Wrapper classes
  • 26. 26 Java Applications  We can develop two types of Java programs:  Stand-alone applications  Web applications (applets)
  • 27. 27 Java better than C++ ?  No Typedefs, Defines, or Preprocessor  No Global Variables  No Goto statements  No Pointers  No Unsafe Structures  No Multiple Inheritance  No Operator Overloading  No Automatic Coercions  No Fragile Data Types ?
  • 28. 28 Object Oriented Languages -A Comparison Feature C++ Objective C Ada Java Encapsulation Yes Yes Yes Yes Inheritance Yes Yes No Yes Multiple Inherit. Yes Yes No No Polymorphism Yes Yes Yes Yes Binding (Early or Late) Both Both Early Late Concurrency Poor Poor Difficult Yes Garbage Collection No Yes No Yes Genericity Yes No Yes Limited Class Libraries Yes Yes Limited Yes
  • 29. 29 Basic Structure that almost use in every java program Wrapper Class Main MethodMain Method Class NameClass Name Package Name Body of Main methodBody of Main method Java Application Save with class name and .java extension Java Application Save with class name and .java extension Public keyword specified that main() function accessible outside the class The void specifies means that main() does not return any values Static keyword specified that main() exists without any object be defined The outer class may a public or default The inner class may a public private, protected or default
  • 30. 30 Short Detail of previous Image  Package:-  A package have many classes Same type of classes are store in same package.  Public:-  The Public keyword specified that main() function accessible outside the class  Class Name:-  Class name is user define.  Class:-  is Keyword that is optional.  Static:-  The Static keyword specified that main() exists without any object be defined  Void main:-  Main Method  String[]:-  Wrapper Class  Arg:-  Arguments
  • 31. 31 Variable in Java  Variable is used to access data .  We use variable to store data.  Variable use for get input from user.  Variable used for give output to user.
  • 32. 32 Variable Declaration  We declare a variable in java same as in C++.  Syntax: Data_type variable_name;  DataTypes:  Data_types used for defined type of variable for example you store (10) integer data. We use int data type.  Varible_name:  Variable name is user defined. we can declare variable name following variable declaration rules
  • 33. 33 Data Types  Data Types that define which type of value used in program  There are many data types of java  Integer Data types Declaration of integer Variable Data_types Variablename;
  • 34. 34 Data types  Floating Data types Declaration of Floating Variable Data_types Variablename;
  • 35. 35 Java Output We use “System.out.println()” for print any message or result on screen. System.out.println(“ “) This is the name of class that contains the object out This is the name of class that contains the object out This is a static variable that in system class This is a static variable that in system class This a method in object out Whatever you specify between parenthesis () is passed to the println( ) method and displayed
  • 36. 36 System.out.println(); System.out.println(); It is used to display message, result and Message+Result. System is a class that is in java.lang package. Java.lang package by default import in netbean IDE. In println() method, “ln” use for new line.
  • 37. 37 System.out.println()  It used for 3 purpose “Message” , ”Result” and “Message + result” System.out.println(); Message Result Message + Result
  • 38. 38 System.out.println()/print(); Message Write Message in Double Quotes(” ”). Message Display as it we Write in Double Quotes.
  • 39. 39 System.out.println()/print(); Result Write Result in without Double Quotes(” ”). What is 15? Sum of two numbers? OR Product of two numbers?
  • 40. 40 System.out.println()/print(); Message+Result Write Message in Double Quotes(” ”). Write Result in without Double Quotes(” ”). For concatenation Message and result use plus(+) operator. Message Result OutputConcate.. .
  • 42. 42 Input in Java  For input in java  We import a scanner  We create a scanner object  We use methods. Firstly import Scanner Create object Use methods It is class name Object name it is user defined It is Constructer For Integer Number More function
  • 45. 45 Code of previous Image package javaapplication6; import java.util.*; public class JavaApplication6 { public static void main(String[] args) { Scanner obj=new Scanner(System.in); int num1,num2; System.out.print("Enter first integer number ::"); num1=obj.nextInt(); System.out.print("Enter Second integer number ::"); num2=obj.nextInt(); System.out.println(num1+"+"+num2+"="+(num1+num2)); } }