SlideShare a Scribd company logo
1 of 16
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

What's hot (20)

NLP_KASHK:Minimum Edit Distance
NLP_KASHK:Minimum Edit DistanceNLP_KASHK:Minimum Edit Distance
NLP_KASHK:Minimum Edit Distance
 
Array
ArrayArray
Array
 
Sienna 12 huffman
Sienna 12 huffmanSienna 12 huffman
Sienna 12 huffman
 
An Introduction : Python
An Introduction : PythonAn Introduction : Python
An Introduction : Python
 
Spell checker using Natural language processing
Spell checker using Natural language processing Spell checker using Natural language processing
Spell checker using Natural language processing
 
TRIES_data_structure
TRIES_data_structureTRIES_data_structure
TRIES_data_structure
 
Do not delete!
Do not delete!Do not delete!
Do not delete!
 
Huffman
HuffmanHuffman
Huffman
 
Mca1010 fundamentals of computer and it
Mca1010  fundamentals of computer and itMca1010  fundamentals of computer and it
Mca1010 fundamentals of computer and it
 
java programming basics - part ii
 java programming basics - part ii java programming basics - part ii
java programming basics - part ii
 
[ppt]
[ppt][ppt]
[ppt]
 
Structures in c language
Structures in c languageStructures in c language
Structures in c language
 
Python - variable types
Python - variable typesPython - variable types
Python - variable types
 
Ir models
Ir modelsIr models
Ir models
 
Term weighting
Term weightingTerm weighting
Term weighting
 
Strings in Python
Strings in PythonStrings in Python
Strings in Python
 
Python strings
Python stringsPython strings
Python strings
 
Java -lec-6
Java -lec-6Java -lec-6
Java -lec-6
 
Data types in python
Data types in pythonData types in python
Data types in python
 
C# chap 10
C# chap 10C# chap 10
C# chap 10
 

Similar to Data types (20)

Java - Basic Datatypes.pptx
Java - Basic Datatypes.pptxJava - Basic Datatypes.pptx
Java - Basic Datatypes.pptx
 
Data types
Data typesData types
Data types
 
Python slide.1
Python slide.1Python slide.1
Python slide.1
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
5. variables & data types
5. variables & data types5. variables & data types
5. variables & data types
 
Datatypes in c
Datatypes in cDatatypes in c
Datatypes in c
 
Data types in C
Data types in CData types in C
Data types in C
 
VHDL- data types
VHDL- data typesVHDL- data types
VHDL- data types
 
Datatypes
DatatypesDatatypes
Datatypes
 
Python Datatypes by SujithKumar
Python Datatypes by SujithKumarPython Datatypes by SujithKumar
Python Datatypes by SujithKumar
 
UNIT-1(Lesson 5).pptx
UNIT-1(Lesson 5).pptxUNIT-1(Lesson 5).pptx
UNIT-1(Lesson 5).pptx
 
Chapter 4 (Part II) - Array and Strings.pdf
Chapter 4 (Part II) - Array and Strings.pdfChapter 4 (Part II) - Array and Strings.pdf
Chapter 4 (Part II) - Array and Strings.pdf
 
Programming Fundamentals lecture 6
Programming Fundamentals lecture 6Programming Fundamentals lecture 6
Programming Fundamentals lecture 6
 
Lect5
Lect5Lect5
Lect5
 
C++ data types
C++ data typesC++ data types
C++ data types
 
Literals, primitive datatypes, variables, expressions, identifiers
Literals, primitive datatypes, variables, expressions, identifiersLiterals, primitive datatypes, variables, expressions, identifiers
Literals, primitive datatypes, variables, expressions, identifiers
 
JAVA PROGRAMMING : Data types
JAVA PROGRAMMING : Data typesJAVA PROGRAMMING : Data types
JAVA PROGRAMMING : Data types
 
What are variables and keywords in c++
What are variables and keywords in c++What are variables and keywords in c++
What are variables and keywords in c++
 
Data types
Data typesData types
Data types
 
JAVA LESSON-01.pptx
JAVA LESSON-01.pptxJAVA LESSON-01.pptx
JAVA LESSON-01.pptx
 

Recently uploaded

Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 

Recently uploaded (20)

Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 

Data types

  • 1.
  • 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;