SlideShare a Scribd company logo
Data types
A data type is used to declare a variable. Every variable
should be declared before initialization.
Primitive data type Non Primitive data type
Boolean
Byte
Char
Short
Int
Long
Float
Double
String
Array
Class
 Byte-(Size is 2 byte)
*Its integer with small range
*Byte data type is an 8-bit signed two's complement integer.
*Minimum value is -128 (-2^7)
*Maximum value is 127 (inclusive)(2^7 -1)
* Default value is 0
* Byte data type is used to save space in large arrays, mainly in place of integers,
since a byte is four times smaller than an integer.
 Boolean-(T/F)(size is 1 byte)
Its true or false .by default its false
boolean data type represents one bit of information
There are only two possible values: true and false
Char –(size is 2 byte)
 char data type is a single 16-bit Unicode character
 Minimum value is 0
 Maximum value is 65,535
 Char data type is used to store any character from keyboard(0-
9,A-Z,a-z)
 Example: char letterA = 'A‘
 Short-(size is 2 bytes)
Its also integer type
 Short data type is a 16-bit signed two's complement integer
 Minimum value is -32,768 (-2^15)
 Maximum value is 32,767 (inclusive) (2^15 -1)
 Short data type can also be used to save memory as byte data type. A short is 2
times smaller than an integer
 Default value is 0.
 Example: short s = 10000, short r = -20000
 Int- (size is 4 bytes)
Its also integer data type with bigger size.
 Int data type is a 32-bit signed two's complement integer.
 Minimum value is - 2,147,483,648 (-2^31)
 Maximum value is 2,147,483,647(inclusive) (2^31 -1)
 Integer is generally used as the default data type for integral values unless there
is a concern about memory.
 The default value is 0
 Example: int a = 100000, int b = -200000
 Long- (size is 8 bytes)
Its also integer data type with more size
 Long data type is a 64-bit signed two's complement integer
 Minimum value is -9,223,372,036,854,775,808(-2^63)
 Maximum value is 9,223,372,036,854,775,807 (inclusive)(2^63 -1)
 This type is used when a wider range than int is needed
 Default value is 0L
 Example: long a = 100000L, long b = -200000L
 Float-(size is 4 bytes)
Used for decimal values
Float is mainly used to save memory in large arrays of floating point numbers
Default value is 0.0f
Float data type is never used for precise values such as currency
Example: float f1 = 234.5f
 Double- (size is 8 bytes)
- double data type is a double-precision 64-bit
- This data type is generally used as the default data type for decimal values,
generally the default choice.
- Double data type should never be used for precise values such as currency.
- Default value is 0.0d
- Example: double d1 = 123.4
 In computer science, the precision is usually measured in bits, but sometimes in
decimal digits. i.e no of digits after decimal point
 Float and double are two of the data types used to represent decimal values or
floating point literals in the Java programming language.
 Float is basically single precision and it can represent decimal values up to 7
digits of precision
 double can represent decimal values up to 16 digits of precision.
 Single Precision is a 32-bit type; Double Precision is a 64-bit type. Accordingly,
Doubles store a much broader range of values, and with much more precision.
 For example
If 10/3 is
3.3333333 ..its single precision
But if its 3.33333333333333..its double precision
By default java takes double precision.
String
 In Java, string is basically an object that represents sequence of char values. An
array of characters works same as Java string. For example: char[]
ch={'j','a','v','a','t','p','o','i','n','t'};
 a string is used to represent text rather than numbers. ... For example, the word
“java" and the phrase “I study java" are both strings. “34567" can be defined as
string if defined properly.
 The length of a string is determined by a termination null character.”0”. So a
string (“java”) has five characters. ‘j’,’a’,’v’,’a’. And null character ‘0’.
 An array is a container object that holds fixed number of values of a single type.
 Length of an array is decided when array is created.after creation its length is
fixed.
 A class can be defined as a template/blueprint that describes the behavior/state
that the object of its type support.
Public class dog
{
String breed;
Int age;
String color;

More Related Content

PPTX
Computer programming 2 Lesson 5
PPS
Data types ,variables,array
PDF
اسلاید دوم جلسه دوم کلاس پایتون برای هکرهای قانونی
PDF
Learning VB.NET Programming Concepts
PPTX
Data types - brainsmartlabs
PPTX
Data types vbnet
PPTX
ODP
JAVA Data Types - Part 1
Computer programming 2 Lesson 5
Data types ,variables,array
اسلاید دوم جلسه دوم کلاس پایتون برای هکرهای قانونی
Learning VB.NET Programming Concepts
Data types - brainsmartlabs
Data types vbnet
JAVA Data Types - Part 1

What's hot (20)

PPTX
NLP_KASHK:Minimum Edit Distance
PDF
Sienna 12 huffman
PPTX
An Introduction : Python
PPTX
Spell checker using Natural language processing
PPTX
TRIES_data_structure
PPTX
Do not delete!
PDF
Huffman
DOCX
Mca1010 fundamentals of computer and it
PPTX
java programming basics - part ii
PPT
[ppt]
PPTX
Structures in c language
PDF
Python - variable types
PPT
Ir models
PPTX
Term weighting
PPTX
Strings in Python
PDF
Python strings
PDF
Java -lec-6
PDF
Data types in python
PDF
NLP_KASHK:Minimum Edit Distance
Sienna 12 huffman
An Introduction : Python
Spell checker using Natural language processing
TRIES_data_structure
Do not delete!
Huffman
Mca1010 fundamentals of computer and it
java programming basics - part ii
[ppt]
Structures in c language
Python - variable types
Ir models
Term weighting
Strings in Python
Python strings
Java -lec-6
Data types in python
Ad

Similar to Data types (20)

PPTX
DATA TYPES in Python done by Sanajai of MCA
PPTX
5. variables & data types
PPTX
Java - Basic Datatypes.pptx
PPTX
Datatype introduction- JAVA
PPTX
Computer Programming Java Data Types.pptx
PPSX
Java session3
PDF
Java basic datatypes
PPTX
a variable in Java must be a specified data type
PDF
Java basic datatypes
PPTX
Topic-5_-Programming-Fundamentals-Part-2.pptx
PPTX
Lecture 2 introduction to Programming languages C.pptx
PPTX
JAVA LESSON-01.pptx
PPTX
03 and 04 .Operators, Expressions, working with the console and conditional s...
DOCX
Data Type is a basic classification which identifies.docx
PPTX
This is a python data types ppt it is used for bca student also
PPTX
DATATYPES IN JAVA primitive and nonprimitive.pptx
PPTX
PPTX
Java_Access_Specifiers_and_Data_Types.pptx
PDF
CIS 1403 Lab 2- Data Types and Variables
PPTX
Java data types
DATA TYPES in Python done by Sanajai of MCA
5. variables & data types
Java - Basic Datatypes.pptx
Datatype introduction- JAVA
Computer Programming Java Data Types.pptx
Java session3
Java basic datatypes
a variable in Java must be a specified data type
Java basic datatypes
Topic-5_-Programming-Fundamentals-Part-2.pptx
Lecture 2 introduction to Programming languages C.pptx
JAVA LESSON-01.pptx
03 and 04 .Operators, Expressions, working with the console and conditional s...
Data Type is a basic classification which identifies.docx
This is a python data types ppt it is used for bca student also
DATATYPES IN JAVA primitive and nonprimitive.pptx
Java_Access_Specifiers_and_Data_Types.pptx
CIS 1403 Lab 2- Data Types and Variables
Java data types
Ad

Recently uploaded (20)

PDF
project resource management chapter-09.pdf
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
STKI Israel Market Study 2025 version august
PDF
Getting started with AI Agents and Multi-Agent Systems
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Developing a website for English-speaking practice to English as a foreign la...
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
Getting Started with Data Integration: FME Form 101
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
PPTX
1. Introduction to Computer Programming.pptx
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PDF
Zenith AI: Advanced Artificial Intelligence
project resource management chapter-09.pdf
NewMind AI Weekly Chronicles – August ’25 Week III
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Univ-Connecticut-ChatGPT-Presentaion.pdf
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
STKI Israel Market Study 2025 version august
Getting started with AI Agents and Multi-Agent Systems
Group 1 Presentation -Planning and Decision Making .pptx
1 - Historical Antecedents, Social Consideration.pdf
A comparative study of natural language inference in Swahili using monolingua...
Assigned Numbers - 2025 - Bluetooth® Document
Developing a website for English-speaking practice to English as a foreign la...
OMC Textile Division Presentation 2021.pptx
DP Operators-handbook-extract for the Mautical Institute
Getting Started with Data Integration: FME Form 101
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
1. Introduction to Computer Programming.pptx
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
Zenith AI: Advanced Artificial Intelligence

Data types

  • 2. A data type is used to declare a variable. Every variable should be declared before initialization.
  • 3. Primitive data type Non Primitive data type Boolean Byte Char Short Int Long Float Double String Array Class
  • 4.  Byte-(Size is 2 byte) *Its integer with small range *Byte data type is an 8-bit signed two's complement integer. *Minimum value is -128 (-2^7) *Maximum value is 127 (inclusive)(2^7 -1) * Default value is 0 * Byte data type is used to save space in large arrays, mainly in place of integers, since a byte is four times smaller than an integer.
  • 5.  Boolean-(T/F)(size is 1 byte) Its true or false .by default its false boolean data type represents one bit of information There are only two possible values: true and false
  • 6. Char –(size is 2 byte)  char data type is a single 16-bit Unicode character  Minimum value is 0  Maximum value is 65,535  Char data type is used to store any character from keyboard(0- 9,A-Z,a-z)  Example: char letterA = 'A‘
  • 7.  Short-(size is 2 bytes) Its also integer type  Short data type is a 16-bit signed two's complement integer  Minimum value is -32,768 (-2^15)  Maximum value is 32,767 (inclusive) (2^15 -1)  Short data type can also be used to save memory as byte data type. A short is 2 times smaller than an integer  Default value is 0.  Example: short s = 10000, short r = -20000
  • 8.  Int- (size is 4 bytes) Its also integer data type with bigger size.  Int data type is a 32-bit signed two's complement integer.  Minimum value is - 2,147,483,648 (-2^31)  Maximum value is 2,147,483,647(inclusive) (2^31 -1)  Integer is generally used as the default data type for integral values unless there is a concern about memory.  The default value is 0  Example: int a = 100000, int b = -200000
  • 9.  Long- (size is 8 bytes) Its also integer data type with more size  Long data type is a 64-bit signed two's complement integer  Minimum value is -9,223,372,036,854,775,808(-2^63)  Maximum value is 9,223,372,036,854,775,807 (inclusive)(2^63 -1)  This type is used when a wider range than int is needed  Default value is 0L  Example: long a = 100000L, long b = -200000L
  • 10.  Float-(size is 4 bytes) Used for decimal values Float is mainly used to save memory in large arrays of floating point numbers Default value is 0.0f Float data type is never used for precise values such as currency Example: float f1 = 234.5f
  • 11.  Double- (size is 8 bytes) - double data type is a double-precision 64-bit - This data type is generally used as the default data type for decimal values, generally the default choice. - Double data type should never be used for precise values such as currency. - Default value is 0.0d - Example: double d1 = 123.4
  • 12.  In computer science, the precision is usually measured in bits, but sometimes in decimal digits. i.e no of digits after decimal point  Float and double are two of the data types used to represent decimal values or floating point literals in the Java programming language.  Float is basically single precision and it can represent decimal values up to 7 digits of precision  double can represent decimal values up to 16 digits of precision.  Single Precision is a 32-bit type; Double Precision is a 64-bit type. Accordingly, Doubles store a much broader range of values, and with much more precision.
  • 13.  For example If 10/3 is 3.3333333 ..its single precision But if its 3.33333333333333..its double precision By default java takes double precision.
  • 14. String  In Java, string is basically an object that represents sequence of char values. An array of characters works same as Java string. For example: char[] ch={'j','a','v','a','t','p','o','i','n','t'};  a string is used to represent text rather than numbers. ... For example, the word “java" and the phrase “I study java" are both strings. “34567" can be defined as string if defined properly.  The length of a string is determined by a termination null character.”0”. So a string (“java”) has five characters. ‘j’,’a’,’v’,’a’. And null character ‘0’.
  • 15.  An array is a container object that holds fixed number of values of a single type.  Length of an array is decided when array is created.after creation its length is fixed.
  • 16.  A class can be defined as a template/blueprint that describes the behavior/state that the object of its type support. Public class dog { String breed; Int age; String color;