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

What's hot (20)

PPTX
Introduction to java
Java Lover
 
PDF
Basic Java Programming
Math-Circle
 
PDF
Introduction to Java
Professional Guru
 
PPTX
Introduction to java
Saba Ameer
 
PPT
Java buzzwords
ramesh517
 
PDF
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Edureka!
 
PPTX
Presentation on Core java
mahir jain
 
PPT
Core java slides
Abhilash Nair
 
PDF
Introduction to Java Programming Language
jaimefrozr
 
PPTX
Introduction to java
Veerabadra Badra
 
PPTX
Java swing
Apurbo Datta
 
PPTX
core java
Roushan Sinha
 
PPTX
Basic Concepts of OOPs (Object Oriented Programming in Java)
Michelle Anne Meralpis
 
PPTX
Core Java Tutorials by Mahika Tutorials
Mahika Tutorials
 
PPTX
Inheritance in java
Tech_MX
 
PDF
What Is Java | Java Tutorial | Java Programming | Learn Java | Edureka
Edureka!
 
PPTX
Core Java
NA
 
PPTX
Core java
sharad soni
 
PPTX
Java program structure
shalinikarunakaran1
 
Introduction to java
Java Lover
 
Basic Java Programming
Math-Circle
 
Introduction to Java
Professional Guru
 
Introduction to java
Saba Ameer
 
Java buzzwords
ramesh517
 
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Edureka!
 
Presentation on Core java
mahir jain
 
Core java slides
Abhilash Nair
 
Introduction to Java Programming Language
jaimefrozr
 
Introduction to java
Veerabadra Badra
 
Java swing
Apurbo Datta
 
core java
Roushan Sinha
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Michelle Anne Meralpis
 
Core Java Tutorials by Mahika Tutorials
Mahika Tutorials
 
Inheritance in java
Tech_MX
 
What Is Java | Java Tutorial | Java Programming | Learn Java | Edureka
Edureka!
 
Core Java
NA
 
Core java
sharad soni
 
Java program structure
shalinikarunakaran1
 

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)

PDF
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PPTX
Controller Request and Response in Odoo18
Celine George
 
PPTX
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
PPTX
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPTX
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
PDF
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
PPTX
Introduction to Indian Writing in English
Trushali Dodiya
 
PDF
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PDF
epi editorial commitee meeting presentation
MIPLM
 
PPTX
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
PPTX
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
PDF
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
PPTX
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PDF
Horarios de distribución de agua en julio
pegazohn1978
 
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
Controller Request and Response in Odoo18
Celine George
 
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
Introduction to Indian Writing in English
Trushali Dodiya
 
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
epi editorial commitee meeting presentation
MIPLM
 
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
Horarios de distribución de agua en julio
pegazohn1978
 
Ad

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)); } }