SlideShare a Scribd company logo
ADVANCED JAVA PROGRAMMING
Presented By
S.Vijayalakshmi B.E,
Assistant Professor,
Department of Computer Science,
Sri Sarada Niketan College for Women, Karur.
 Java is a programming language and a platform.
Java is a high level, robust, object-oriented and
secure programming language.
 Java was developed by Sun Microsystems (which
is now the subsidiary of Oracle) in the year 1995.
 James Gosling is known as the father of Java.
Before Java, its name was Oak. Since Oak was
already a registered company, so James Gosling
and his team changed the name from Oak to Java.
What is Java?
 James Gosling initiated Java language project in
June 1991 for use in one of his many set-top box
projects. The language, initially called ‘Oak’ after
an oak tree that stood outside Gosling's office,
also went by the name ‘Green’ and ended up later
being renamed as Java, from a list of random
words.
 Sun released the first public implementation as
Java 1.0 in 1995.
 It promised Write Once, Run
Anywhere (WORA), providing no-cost run-times
on popular platforms.
HISTORY OF JAVA
 On 13 November, 2006, Sun released much of Java as
free and open source software under the terms of the
GNU General Public License (GPL).
 On 8 May, 2007, Sun finished the process, making all
of Java's core code free and open-source, aside from a
small portion of code to which Sun did not hold the
copyright.
HISTORY OF JAVA (Conti…)
 JDK Alpha and Beta (1995)
 JDK 1.0 (23rd Jan 1996)
 JDK 1.1 (19th Feb 1997)
 J2SE 1.2 (8th Dec 1998)
 J2SE 1.3 (8th May 2000)
 J2SE 1.4 (6th Feb 2002)
 J2SE 5.0 (30th Sep 2004)
 Java SE 6 (11th Dec 2006)
 Java SE 7 (28th July 2011)
 Java SE 8 (18th Mar 2014)
Java Version History
 Java SE 9 (21st Sep 2017)
 Java SE 10 (20th Mar 2018)
 Java SE 11 (September 2018)
 Java SE 12 (March 2019)
 Java SE 13 (September 2019)
 Java SE 14 (Mar 2020)
 Java SE 15 (September 2020)
 Java SE 16 (Mar 2021)
 Java SE 17 (September 2021)
 Java SE 18 (to be released by March 2022)
Java Version History(conti…)
According to Sun, 3 billion devices run Java. There
are many devices where Java is currently used.
Some of them are as follows:
 Desktop Applications such as acrobat reader, media
player, antivirus, etc.
 Web Applications such as irctc.co.in, javatpoint.com,
etc.
 Enterprise Applications such as banking applications.
 Mobile
 Embedded System
 Smart Card
 Robotics
 Games, etc.
Java Applications
There are mainly 4 types of applications that can be created
using Java programming:
 1) Standalone Application
Standalone applications are also known as desktop applications or
window-based applications. These are traditional software that we
need to install on every machine. Examples of standalone
application are Media player, antivirus, etc. AWT and Swing are
used in Java for creating standalone applications.
 2) Web Application
An application that runs on the server side and creates a dynamic
page is called a web application. Currently, Servlet, JSP, Struts,
Spring, Hibernate, JSF, etc. technologies are used for creating web
applications in Java.
Types of Java Applications
 3) Enterprise Application
An application that is distributed in nature, such
as banking applications, etc. is called an
enterprise application. It has advantages like
high-level security, load balancing, and clustering.
In Java, EJB is used for creating enterprise
applications.
 4) Mobile Application
An application which is created for mobile devices
is called a mobile application. Currently, Android
and Java ME are used for creating mobile
applications.
Types of Java Applications(Conti…)
Data types specify the different sizes and values
that can be stored in the variable. There are two
types of data types in Java:
 Primitive data types: The primitive data types
include boolean, char, byte, short, int, long, float and
double.
 Non-primitive data types: The non-primitive data
types include Classes, Interfaces, and Arrays.
Data Types in Java
In Java language, primitive data types are the building
blocks of data manipulation. These are the most basic data
types available in Java language. There are 8 types of
primitive data types:
 boolean data type
 byte data type
 char data type
 short data type
 int data type
 long data type
 float data type
 double data type
Java Primitive Data Types
Data Types in Java
 The Boolean data type is used to store only
two possible values: true and false. This data
type is used for simple flags that track
true/false conditions.
 The Boolean data type specifies one bit of
information, but its "size" can't be defined
precisely.
 Example:
Boolean one = false
Boolean Data Type
 The byte data type is an example of primitive data
type. It isan 8-bit signed two's complement integer.
Its value-range lies between -128 to 127 (inclusive).
Its minimum value is -128 and maximum value is
127. Its default value is 0.
 The byte data type is used to save memory in large
arrays where the memory savings is most
required. It saves space because a byte is 4 times
smaller than an integer. It can also be used in place
of "int" data type.
 Example:
byte a = 10, byte b = -20
Byte Data Type
 The short data type is a 16-bit signed two's
complement integer. Its value-range lies
between -32,768 to 32,767 (inclusive). Its
minimum value is -32,768 and maximum value
is 32,767. Its default value is 0.
 The short data type can also be used to save
memory just like byte data type. A short data
type is 2 times smaller than an integer.
 Example:
short s = 10000, short r = -5000
Short Data Type
 The int data type is a 32-bit signed two's
complement integer. Its value-range lies
between - 2,147,483,648 (-2^31) to
2,147,483,647 (2^31 -1) (inclusive). Its minimum
value is - 2,147,483,648and maximum value is
2,147,483,647. Its default value is 0.
 The int data type is generally used as a default
data type for integral values unless if there is
no problem about memory.
 Example:
int a = 100000, int b = -200000
Int Data Type
 The long data type is a 64-bit two's complement
integer. Its value-range lies between -
9,223,372,036,854,775,808(-2^63) to
9,223,372,036,854,775,807(2^63 -1)(inclusive).
 Its minimum value is - 9,223,372,036,854,775,808
and maximum value is 9,223,372,036,854,775,807.
 Its default value is 0. The long data type is used
when you need a range of values more than those
provided by int.
 Example:
long a = 100000L, long b = -200000L
Long Data Type
 The float data type is a single-precision 32-bit IEEE
754 floating point.Its value range is unlimited.
 It is recommended to use a float (instead of
double) if you need to save memory in large
arrays of floating point numbers.
 The float data type should never be used for
precise values, such as currency. Its default value
is 0.0F.
 Example:
float f1 = 234.5f
Float Data Type
 The double data type is a double-precision 64-
bit IEEE 754 floating point.
 Its value range is unlimited. The double data
type is generally used for decimal values just
like float.
 The double data type also should never be
used for precise values, such as currency. Its
default value is 0.0d.
 Example:
double d1 = 12.3
Double Data Type
 The char data type is a single 16-bit Unicode
character. Its value-range lies between 'u0000'
(or 0) to 'uffff' (or 65,535 inclusive).
 The char data type is used to store characters.
 Example:
char letterA = 'A'
Char Data Type
 Non-primitive data types are
called reference types because they refer
to objects.
 Examples of non-primitive types are Strings
, Arrays, Classes, Interface, etc.
Non-Primitive Data Types
 Primitive types are predefined (already defined) in
Java. Non-primitive types are created by the
programmer and is not defined by Java (except
for String).
 Non-primitive types can be used to call methods to
perform certain operations, while primitive types
cannot.
 A primitive type has always a value, while non-
primitive types can be null.
 A primitive type starts with a lowercase letter, while
non-primitive types starts with an uppercase letter.
Difference between primitive and non-
primitive data types:
 A variable is a container which holds the
value while the Java program is executed.
 It is a combination of "vary + able" which
means its value can be changed.
 A variable is assigned with a data type.
 Variable is a name of memory location.
 There are three types of variables in java:
local, instance and static.
EX: int data=50;//Here data is variable
Java Variables
 There are three types of variables in Java:
Local variable
Instance variable
Static variable
 1) Local Variable
A variable declared inside the body of the method is
called local variable. You can use this variable only
within that method and the other methods in the class
aren't even aware that the variable exists.
 A local variable cannot be defined with "static"
keyword.
Types of Variables
2) Instance Variable
 A variable declared inside the class but outside
the body of the method, is called an instance
variable. It is not declared as static.
 It is called an instance variable because its
value is instance-specific and is not shared
among instances.
Types of Variables(Conti..)
3) Static variable
 A variable that is declared as static is called a
static variable. It cannot be local. You can
create a single copy of the static variable and
share it among all the instances of the class.
Memory allocation for static variables happens
only once when the class is loaded in the
memory.
Types of Variables(Conti..)
public class A
{
static int m=100; //static variable
void method()
{
int n=90;//local variable
}
public static void main(String args[])
{
int data=50; //instance variable
}
} //end of class
Example to understand the types of variables in java
 Arrays are used to store multiple values in a
single variable, instead of declaring separate
variables for each value.
 To declare an array, define the variable type
with square brackets:
EX: String[] cars;
 We have now declared a variable that holds an
array of strings. To insert values to it, you can
place the values in a comma-separated list, inside
curly braces:
String[] cars = {"Volvo", "BMW", "Ford",
"Mazda"};
 To create an array of integers, you could write:
int[] myNum = {10, 20, 30, 40};
Java Arrays
 You can access an array element by referring to
the index number.
 This statement accesses the value of the first
element in cars:
 Example:
String[] cars = {"Volvo", "BMW", "Ford",
"Mazda"};
System.out.println(cars[0]);
Output: Volvo
Access the Elements of an Array
 To change the value of a specific element,
refer to the index number:
 Example
 cars[0] = "Opel";
 Example
String[] cars = {"Volvo", "BMW", "Ford",
"Mazda"};
cars[0] = "Opel";
System.out.println(cars[0]);
// Now outputs Opel instead of Volvo
Change an Array Element
 To find out how many elements an array has,
use the length property:
 Example
String[] cars = {"Volvo", "BMW", "Ford",
"Mazda"};
System.out.println(cars.length);
Output 4
Array Length
THANK YOU

More Related Content

PPTX
Core java
Shivaraj R
 
PPTX
Core java
Sun Technlogies
 
PPT
Java SpringMVC SpringBOOT (Divergent).ppt
Aayush Chimaniya
 
PPTX
Unit-1_GHD.pptxguguigihihihihihihoihihhi
40NehaPagariya
 
PPTX
Introduction to Java Basics Programming Java Basics-I.pptx
SANDHYAP32
 
PPTX
intro_java (1).pptx
SmitNikumbh
 
PPTX
JAVA Module 1______________________.pptx
Radhika Venkatesh
 
PDF
Java data types, variables and jvm
Madishetty Prathibha
 
Core java
Shivaraj R
 
Core java
Sun Technlogies
 
Java SpringMVC SpringBOOT (Divergent).ppt
Aayush Chimaniya
 
Unit-1_GHD.pptxguguigihihihihihihoihihhi
40NehaPagariya
 
Introduction to Java Basics Programming Java Basics-I.pptx
SANDHYAP32
 
intro_java (1).pptx
SmitNikumbh
 
JAVA Module 1______________________.pptx
Radhika Venkatesh
 
Java data types, variables and jvm
Madishetty Prathibha
 

Similar to Advanced java programming - DATA TYPES, VARIABLES, ARRAYS (20)

PPTX
Java platform
Visithan
 
PPTX
JAVA LESSON-01.pptx
StephenOczon1
 
DOC
java handout.doc
SOMOSCO1
 
PPSX
Java session3
Jigarthacker
 
PPTX
L2 datatypes and variables
teach4uin
 
PPTX
Computer programming 2 Lesson 5
MLG College of Learning, Inc
 
PPTX
COMPUTER PROGRAMMING LANGUAGE.pptx
SofiaArquero2
 
PPTX
Java - Basic Datatypes.pptx
Nagaraju Pamarthi
 
PPTX
Java OOP Concepts 1st Slide
sunny khan
 
PPTX
DATATYPES IN JAVA primitive and nonprimitive.pptx
mustaq4
 
PPTX
Data types IN JAVA
garishma bhatia
 
PPTX
a variable in Java must be a specified data type
Kavitha S
 
PPTX
UNIT 1.pptx
EduclentMegasoftel
 
PPTX
5. variables & data types
M H Buddhika Ariyaratne
 
PPTX
This is a python data types ppt it is used for bca student also
sandhiyamaliga2005
 
PPTX
Computer Programming Java Data Types.pptx
MarianneIsid
 
PPTX
Java UNITbgbgbfdbv v bbfbf cvbgfbvc gf 1.pptx
hofon47654
 
PPT
Java introduction
GaneshKumarKanthiah
 
PPTX
java programming basics - part ii
jyoti_lakhani
 
PPTX
Introduction to Java Programming
One97 Communications Limited
 
Java platform
Visithan
 
JAVA LESSON-01.pptx
StephenOczon1
 
java handout.doc
SOMOSCO1
 
Java session3
Jigarthacker
 
L2 datatypes and variables
teach4uin
 
Computer programming 2 Lesson 5
MLG College of Learning, Inc
 
COMPUTER PROGRAMMING LANGUAGE.pptx
SofiaArquero2
 
Java - Basic Datatypes.pptx
Nagaraju Pamarthi
 
Java OOP Concepts 1st Slide
sunny khan
 
DATATYPES IN JAVA primitive and nonprimitive.pptx
mustaq4
 
Data types IN JAVA
garishma bhatia
 
a variable in Java must be a specified data type
Kavitha S
 
UNIT 1.pptx
EduclentMegasoftel
 
5. variables & data types
M H Buddhika Ariyaratne
 
This is a python data types ppt it is used for bca student also
sandhiyamaliga2005
 
Computer Programming Java Data Types.pptx
MarianneIsid
 
Java UNITbgbgbfdbv v bbfbf cvbgfbvc gf 1.pptx
hofon47654
 
Java introduction
GaneshKumarKanthiah
 
java programming basics - part ii
jyoti_lakhani
 
Introduction to Java Programming
One97 Communications Limited
 
Ad

More from vijayalakshmis184431 (13)

PPTX
Advanced Operating Systems- Mobile OS and ARM
vijayalakshmis184431
 
PPTX
Advanced Operating Systems- Process Synchronization
vijayalakshmis184431
 
PPTX
Advanced Operating Systems- Synchronization primitives in os
vijayalakshmis184431
 
PPTX
Advanced Operating Systems- Kernal Structure and native level
vijayalakshmis184431
 
PPTX
Advanced Operating Systems- Distributed Scheduling and shared memory
vijayalakshmis184431
 
PPTX
Advanced Operating Systems- Distributed file system and caching
vijayalakshmis184431
 
PPTX
Advanced Operating Systems- Distributed OS
vijayalakshmis184431
 
PPTX
Advanced Operating Systems- Clock synchronization and mutual exclusive
vijayalakshmis184431
 
PPTX
Advanced Operating Systems- Multiprocessor OS
vijayalakshmis184431
 
PPTX
Advanced Java Programming - Enterprise Java Beans client
vijayalakshmis184431
 
PPTX
Computer Networks - Error Detection and Correction
vijayalakshmis184431
 
PPTX
Computer Networks - OSI Model and its functions
vijayalakshmis184431
 
PPTX
Computer Networks - Network Topologies, Application of Networks, Different ty...
vijayalakshmis184431
 
Advanced Operating Systems- Mobile OS and ARM
vijayalakshmis184431
 
Advanced Operating Systems- Process Synchronization
vijayalakshmis184431
 
Advanced Operating Systems- Synchronization primitives in os
vijayalakshmis184431
 
Advanced Operating Systems- Kernal Structure and native level
vijayalakshmis184431
 
Advanced Operating Systems- Distributed Scheduling and shared memory
vijayalakshmis184431
 
Advanced Operating Systems- Distributed file system and caching
vijayalakshmis184431
 
Advanced Operating Systems- Distributed OS
vijayalakshmis184431
 
Advanced Operating Systems- Clock synchronization and mutual exclusive
vijayalakshmis184431
 
Advanced Operating Systems- Multiprocessor OS
vijayalakshmis184431
 
Advanced Java Programming - Enterprise Java Beans client
vijayalakshmis184431
 
Computer Networks - Error Detection and Correction
vijayalakshmis184431
 
Computer Networks - OSI Model and its functions
vijayalakshmis184431
 
Computer Networks - Network Topologies, Application of Networks, Different ty...
vijayalakshmis184431
 
Ad

Recently uploaded (20)

PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PDF
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
PDF
3.The-Rise-of-the-Marathas.pdfppt/pdf/8th class social science Exploring Soci...
Sandeep Swamy
 
PPTX
PREVENTIVE PEDIATRIC. pptx
AneetaSharma15
 
PPTX
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
DOCX
UPPER GASTRO INTESTINAL DISORDER.docx
BANDITA PATRA
 
DOCX
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
MartinaBurlando1
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
PPTX
Strengthening open access through collaboration: building connections with OP...
Jisc
 
PPTX
Software Engineering BSC DS UNIT 1 .pptx
Dr. Pallawi Bulakh
 
PDF
Sunset Boulevard Student Revision Booklet
jpinnuck
 
PDF
7.Particulate-Nature-of-Matter.ppt/8th class science curiosity/by k sandeep s...
Sandeep Swamy
 
PPTX
Congenital Hypothyroidism pptx
AneetaSharma15
 
PPTX
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
PDF
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
PDF
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
PPTX
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
PDF
Arihant Class 10 All in One Maths full pdf
sajal kumar
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
3.The-Rise-of-the-Marathas.pdfppt/pdf/8th class social science Exploring Soci...
Sandeep Swamy
 
PREVENTIVE PEDIATRIC. pptx
AneetaSharma15
 
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
UPPER GASTRO INTESTINAL DISORDER.docx
BANDITA PATRA
 
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
NOI Hackathon - Summer Edition - GreenThumber.pptx
MartinaBurlando1
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
Strengthening open access through collaboration: building connections with OP...
Jisc
 
Software Engineering BSC DS UNIT 1 .pptx
Dr. Pallawi Bulakh
 
Sunset Boulevard Student Revision Booklet
jpinnuck
 
7.Particulate-Nature-of-Matter.ppt/8th class science curiosity/by k sandeep s...
Sandeep Swamy
 
Congenital Hypothyroidism pptx
AneetaSharma15
 
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
Arihant Class 10 All in One Maths full pdf
sajal kumar
 

Advanced java programming - DATA TYPES, VARIABLES, ARRAYS

  • 1. ADVANCED JAVA PROGRAMMING Presented By S.Vijayalakshmi B.E, Assistant Professor, Department of Computer Science, Sri Sarada Niketan College for Women, Karur.
  • 2.  Java is a programming language and a platform. Java is a high level, robust, object-oriented and secure programming language.  Java was developed by Sun Microsystems (which is now the subsidiary of Oracle) in the year 1995.  James Gosling is known as the father of Java. Before Java, its name was Oak. Since Oak was already a registered company, so James Gosling and his team changed the name from Oak to Java. What is Java?
  • 3.  James Gosling initiated Java language project in June 1991 for use in one of his many set-top box projects. The language, initially called ‘Oak’ after an oak tree that stood outside Gosling's office, also went by the name ‘Green’ and ended up later being renamed as Java, from a list of random words.  Sun released the first public implementation as Java 1.0 in 1995.  It promised Write Once, Run Anywhere (WORA), providing no-cost run-times on popular platforms. HISTORY OF JAVA
  • 4.  On 13 November, 2006, Sun released much of Java as free and open source software under the terms of the GNU General Public License (GPL).  On 8 May, 2007, Sun finished the process, making all of Java's core code free and open-source, aside from a small portion of code to which Sun did not hold the copyright. HISTORY OF JAVA (Conti…)
  • 5.  JDK Alpha and Beta (1995)  JDK 1.0 (23rd Jan 1996)  JDK 1.1 (19th Feb 1997)  J2SE 1.2 (8th Dec 1998)  J2SE 1.3 (8th May 2000)  J2SE 1.4 (6th Feb 2002)  J2SE 5.0 (30th Sep 2004)  Java SE 6 (11th Dec 2006)  Java SE 7 (28th July 2011)  Java SE 8 (18th Mar 2014) Java Version History
  • 6.  Java SE 9 (21st Sep 2017)  Java SE 10 (20th Mar 2018)  Java SE 11 (September 2018)  Java SE 12 (March 2019)  Java SE 13 (September 2019)  Java SE 14 (Mar 2020)  Java SE 15 (September 2020)  Java SE 16 (Mar 2021)  Java SE 17 (September 2021)  Java SE 18 (to be released by March 2022) Java Version History(conti…)
  • 7. According to Sun, 3 billion devices run Java. There are many devices where Java is currently used. Some of them are as follows:  Desktop Applications such as acrobat reader, media player, antivirus, etc.  Web Applications such as irctc.co.in, javatpoint.com, etc.  Enterprise Applications such as banking applications.  Mobile  Embedded System  Smart Card  Robotics  Games, etc. Java Applications
  • 8. There are mainly 4 types of applications that can be created using Java programming:  1) Standalone Application Standalone applications are also known as desktop applications or window-based applications. These are traditional software that we need to install on every machine. Examples of standalone application are Media player, antivirus, etc. AWT and Swing are used in Java for creating standalone applications.  2) Web Application An application that runs on the server side and creates a dynamic page is called a web application. Currently, Servlet, JSP, Struts, Spring, Hibernate, JSF, etc. technologies are used for creating web applications in Java. Types of Java Applications
  • 9.  3) Enterprise Application An application that is distributed in nature, such as banking applications, etc. is called an enterprise application. It has advantages like high-level security, load balancing, and clustering. In Java, EJB is used for creating enterprise applications.  4) Mobile Application An application which is created for mobile devices is called a mobile application. Currently, Android and Java ME are used for creating mobile applications. Types of Java Applications(Conti…)
  • 10. Data types specify the different sizes and values that can be stored in the variable. There are two types of data types in Java:  Primitive data types: The primitive data types include boolean, char, byte, short, int, long, float and double.  Non-primitive data types: The non-primitive data types include Classes, Interfaces, and Arrays. Data Types in Java
  • 11. In Java language, primitive data types are the building blocks of data manipulation. These are the most basic data types available in Java language. There are 8 types of primitive data types:  boolean data type  byte data type  char data type  short data type  int data type  long data type  float data type  double data type Java Primitive Data Types
  • 13.  The Boolean data type is used to store only two possible values: true and false. This data type is used for simple flags that track true/false conditions.  The Boolean data type specifies one bit of information, but its "size" can't be defined precisely.  Example: Boolean one = false Boolean Data Type
  • 14.  The byte data type is an example of primitive data type. It isan 8-bit signed two's complement integer. Its value-range lies between -128 to 127 (inclusive). Its minimum value is -128 and maximum value is 127. Its default value is 0.  The byte data type is used to save memory in large arrays where the memory savings is most required. It saves space because a byte is 4 times smaller than an integer. It can also be used in place of "int" data type.  Example: byte a = 10, byte b = -20 Byte Data Type
  • 15.  The short data type is a 16-bit signed two's complement integer. Its value-range lies between -32,768 to 32,767 (inclusive). Its minimum value is -32,768 and maximum value is 32,767. Its default value is 0.  The short data type can also be used to save memory just like byte data type. A short data type is 2 times smaller than an integer.  Example: short s = 10000, short r = -5000 Short Data Type
  • 16.  The int data type is a 32-bit signed two's complement integer. Its value-range lies between - 2,147,483,648 (-2^31) to 2,147,483,647 (2^31 -1) (inclusive). Its minimum value is - 2,147,483,648and maximum value is 2,147,483,647. Its default value is 0.  The int data type is generally used as a default data type for integral values unless if there is no problem about memory.  Example: int a = 100000, int b = -200000 Int Data Type
  • 17.  The long data type is a 64-bit two's complement integer. Its value-range lies between - 9,223,372,036,854,775,808(-2^63) to 9,223,372,036,854,775,807(2^63 -1)(inclusive).  Its minimum value is - 9,223,372,036,854,775,808 and maximum value is 9,223,372,036,854,775,807.  Its default value is 0. The long data type is used when you need a range of values more than those provided by int.  Example: long a = 100000L, long b = -200000L Long Data Type
  • 18.  The float data type is a single-precision 32-bit IEEE 754 floating point.Its value range is unlimited.  It is recommended to use a float (instead of double) if you need to save memory in large arrays of floating point numbers.  The float data type should never be used for precise values, such as currency. Its default value is 0.0F.  Example: float f1 = 234.5f Float Data Type
  • 19.  The double data type is a double-precision 64- bit IEEE 754 floating point.  Its value range is unlimited. The double data type is generally used for decimal values just like float.  The double data type also should never be used for precise values, such as currency. Its default value is 0.0d.  Example: double d1 = 12.3 Double Data Type
  • 20.  The char data type is a single 16-bit Unicode character. Its value-range lies between 'u0000' (or 0) to 'uffff' (or 65,535 inclusive).  The char data type is used to store characters.  Example: char letterA = 'A' Char Data Type
  • 21.  Non-primitive data types are called reference types because they refer to objects.  Examples of non-primitive types are Strings , Arrays, Classes, Interface, etc. Non-Primitive Data Types
  • 22.  Primitive types are predefined (already defined) in Java. Non-primitive types are created by the programmer and is not defined by Java (except for String).  Non-primitive types can be used to call methods to perform certain operations, while primitive types cannot.  A primitive type has always a value, while non- primitive types can be null.  A primitive type starts with a lowercase letter, while non-primitive types starts with an uppercase letter. Difference between primitive and non- primitive data types:
  • 23.  A variable is a container which holds the value while the Java program is executed.  It is a combination of "vary + able" which means its value can be changed.  A variable is assigned with a data type.  Variable is a name of memory location.  There are three types of variables in java: local, instance and static. EX: int data=50;//Here data is variable Java Variables
  • 24.  There are three types of variables in Java: Local variable Instance variable Static variable  1) Local Variable A variable declared inside the body of the method is called local variable. You can use this variable only within that method and the other methods in the class aren't even aware that the variable exists.  A local variable cannot be defined with "static" keyword. Types of Variables
  • 25. 2) Instance Variable  A variable declared inside the class but outside the body of the method, is called an instance variable. It is not declared as static.  It is called an instance variable because its value is instance-specific and is not shared among instances. Types of Variables(Conti..)
  • 26. 3) Static variable  A variable that is declared as static is called a static variable. It cannot be local. You can create a single copy of the static variable and share it among all the instances of the class. Memory allocation for static variables happens only once when the class is loaded in the memory. Types of Variables(Conti..)
  • 27. public class A { static int m=100; //static variable void method() { int n=90;//local variable } public static void main(String args[]) { int data=50; //instance variable } } //end of class Example to understand the types of variables in java
  • 28.  Arrays are used to store multiple values in a single variable, instead of declaring separate variables for each value.  To declare an array, define the variable type with square brackets: EX: String[] cars;  We have now declared a variable that holds an array of strings. To insert values to it, you can place the values in a comma-separated list, inside curly braces: String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};  To create an array of integers, you could write: int[] myNum = {10, 20, 30, 40}; Java Arrays
  • 29.  You can access an array element by referring to the index number.  This statement accesses the value of the first element in cars:  Example: String[] cars = {"Volvo", "BMW", "Ford", "Mazda"}; System.out.println(cars[0]); Output: Volvo Access the Elements of an Array
  • 30.  To change the value of a specific element, refer to the index number:  Example  cars[0] = "Opel";  Example String[] cars = {"Volvo", "BMW", "Ford", "Mazda"}; cars[0] = "Opel"; System.out.println(cars[0]); // Now outputs Opel instead of Volvo Change an Array Element
  • 31.  To find out how many elements an array has, use the length property:  Example String[] cars = {"Volvo", "BMW", "Ford", "Mazda"}; System.out.println(cars.length); Output 4 Array Length