SlideShare a Scribd company logo
1 of 22
Data types and Literals




                          1
Objectives

On completion of this period, you would be able to
 know

•   Data types in Java
•   Literals in Java




                                                     2
Recap


In the previous class we have discussed
   •   White spaces, separators, literals and keywords
   •   Comments in Java




                                                         3
Data types in Java
• Data types in Java are classified into
   • Primitive types
   • Non-primitive types
• Primitive types are also known as simple data
  types
• A primitive type is predefined by the language
• Primitive types are further classified into
   • Numeric types
   • Non-numeric types



                                               4
Data types in Java
• Non-primitive types are also known as reference
  types
• Non-primitive types are
  • Classes
  • Interfaces
  • Arrays




                                                5
The classification of data types in Java
                             Data types in Java



             Primitive                         Non-primitive

 Numeric         Non-numeric
                                            classe            Arrays
                                            s
 integer
                      char                        Interface

Floating point             Boolea
                           n
                         Fig. 6.1 Data types in Java
                                                                  6
Data types

•   Primitive Java data types can be grouped into
    •   integers
    •   floating point numbers
    •   characters
    •   boolean




                                                    7
Integer types

•   Java defines four integer types: byte, short, int and
    long
•   All these are signed, positive and negative values
•   Java does not support unsigned types
•   byte is 8 bit width , short is 16 bit width int is 32
    bit width and long is 64 bit width



                                                            8
byte type

•   The smallest type is byte
•   Range from -128 to +128
•   Byte variables are declared by use of keyword
    ‘byte ‘
     eg.
         byte x, y;




                                                    9
short type

•  short is a signed 16 bit type.
• Its range is from -32,768 to +32,767

• It is probably the least used data type in Java

• Keyword used is ‘short’

eg.
  short x;




                                                    10
int type

•     The most commonly used integer data type is int
•     It has a range of -2,147,483,648 to 2,147,483,647
•     Keyword used is ‘int’
eg.
    int x;




                                                     11
long type
•   long is a signed 64 bit type
•   Useful where an int type is not large enough to hold
    the desired value
•   The range of large is quite large
•   This makes it useful when large, whole numbers are
    needed
•   Keyword used is ‘long’
eg. :
    long seconds;
                                                      12
floating point types

•   floating point numbers are also known as real
    numbers
•   Are used when fractional components are required
•   float and double are two kinds of floating point
    types
•   Keywords used are ‘float’ and ‘double’


                                                       13
Float type

•   float specify a single precision value that uses 32
    bits of storage
•   float type is useful when you require fractional
    component, but does not require a large degree of
    precision
eg.
    float area;

                                                          14
double type

•   double uses 64 bits of storage
•   When you need to maintain accuracy over many
    iterative calculations or manipulating large valued
    numbers double is the best choice
eg. :
    double area;


                                                      15
character type

•   In Java the data type used to store character is char
•   char in Java is different from char in C and C++
•   Java used Unicode to represent characters
•   Unicode was selected because it would help in
    internationalization of Java as a programming
    language
•   Java character is 16 bit type. The range of the
    characters is 0 to 65,536


                                                       16
boolean type

•   boolean data type is used to represent logical
    values that can be either true or false
•   All relational, conditional and logical operators
    return boolean values
•   It used only one bit of storage
•   Keyword used is ‘boolean’
•   eg;.
    •   boolean flag;



                                                        17
The simple data types in Java
•   In summary Java defines eight simple types of
    data. They are
    •   byte
    •   short
    •   int
    •   long
    •   char
    •   float
    •   double
    •   boolean

                                                    18
Summary
•   In this class we have discussed
    •   Data types in Java
    •   Literals in Java




                                      19
Quiz
1.Which of the following data type can store only
   two values
a)   int
b)   float
c)   boolean
d)   All of the above


                                                    20
Quiz

2.String Literal Enclosed with

a)   ‘‘
b)   ““
c)   **
d)   All the Above



                                 21
Frequently Asked Questions

1.   List the different data types available in Java

2.   Explain the various data types available in Java

3.   List the Literal in Java

4.   Explain the Literals in Java



                                                       22

More Related Content

What's hot

Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVAAbhilash Nair
 
Data Types & Variables in JAVA
Data Types & Variables in JAVAData Types & Variables in JAVA
Data Types & Variables in JAVAAnkita Totala
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handlingkamal kotecha
 
Looping statements in Java
Looping statements in JavaLooping statements in Java
Looping statements in JavaJin Castor
 
Java Data Types and Variables
Java Data Types and VariablesJava Data Types and Variables
Java Data Types and Variablessasi saseenthiran
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in JavaNiloy Saha
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVAVINOTH R
 
Constants, Variables and Data Types in Java
Constants, Variables and Data Types in JavaConstants, Variables and Data Types in Java
Constants, Variables and Data Types in JavaAbhilash Nair
 
itft-Decision making and branching in java
itft-Decision making and branching in javaitft-Decision making and branching in java
itft-Decision making and branching in javaAtul Sehdev
 
Java data types, variables and jvm
Java data types, variables and jvm Java data types, variables and jvm
Java data types, variables and jvm Madishetty Prathibha
 
Java string handling
Java string handlingJava string handling
Java string handlingSalman Khan
 

What's hot (20)

Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
 
Data Types & Variables in JAVA
Data Types & Variables in JAVAData Types & Variables in JAVA
Data Types & Variables in JAVA
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
Constructor ppt
Constructor pptConstructor ppt
Constructor ppt
 
Java static keyword
Java static keywordJava static keyword
Java static keyword
 
Looping statements in Java
Looping statements in JavaLooping statements in Java
Looping statements in Java
 
Java constructors
Java constructorsJava constructors
Java constructors
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Java Data Types and Variables
Java Data Types and VariablesJava Data Types and Variables
Java Data Types and Variables
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVA
 
java token
java tokenjava token
java token
 
Constants in java
Constants in javaConstants in java
Constants in java
 
Constants, Variables and Data Types in Java
Constants, Variables and Data Types in JavaConstants, Variables and Data Types in Java
Constants, Variables and Data Types in Java
 
Threads in JAVA
Threads in JAVAThreads in JAVA
Threads in JAVA
 
itft-Decision making and branching in java
itft-Decision making and branching in javaitft-Decision making and branching in java
itft-Decision making and branching in java
 
Applets in java
Applets in javaApplets in java
Applets in java
 
Java data types, variables and jvm
Java data types, variables and jvm Java data types, variables and jvm
Java data types, variables and jvm
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Java string handling
Java string handlingJava string handling
Java string handling
 

Similar to Data types

Similar to Data types (20)

Data types IN JAVA
Data types IN JAVAData types IN JAVA
Data types IN JAVA
 
01 Java Language And OOP PART I
01 Java Language And OOP PART I01 Java Language And OOP PART I
01 Java Language And OOP PART I
 
Variable
VariableVariable
Variable
 
L2 datatypes and variables
L2 datatypes and variablesL2 datatypes and variables
L2 datatypes and variables
 
332 ch07
332 ch07332 ch07
332 ch07
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
ITFT - Java
ITFT - JavaITFT - Java
ITFT - Java
 
Java basic-data-types
Java basic-data-typesJava basic-data-types
Java basic-data-types
 
Java basic data types
Java basic data typesJava basic data types
Java basic data types
 
Java basic data types
Java basic data typesJava basic data types
Java basic data types
 
demo1 java of demo 1 java with demo 1 java.ppt
demo1 java of demo 1 java with demo 1 java.pptdemo1 java of demo 1 java with demo 1 java.ppt
demo1 java of demo 1 java with demo 1 java.ppt
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 
Datatype
DatatypeDatatype
Datatype
 
Data types in Java
Data types in JavaData types in Java
Data types in Java
 
Java Datatypes
Java DatatypesJava Datatypes
Java Datatypes
 
Java session3
Java session3Java session3
Java session3
 
basics dart.pdf
basics dart.pdfbasics dart.pdf
basics dart.pdf
 
Mesics lecture 3 c – constants and variables
Mesics lecture 3   c – constants and variablesMesics lecture 3   c – constants and variables
Mesics lecture 3 c – constants and variables
 
Datatyps in posgresql
Datatyps in posgresqlDatatyps in posgresql
Datatyps in posgresql
 
Chapter 4.pptx
Chapter 4.pptxChapter 4.pptx
Chapter 4.pptx
 

More from myrajendra (20)

Fundamentals
FundamentalsFundamentals
Fundamentals
 
Data type
Data typeData type
Data type
 
Hibernate example1
Hibernate example1Hibernate example1
Hibernate example1
 
Jdbc workflow
Jdbc workflowJdbc workflow
Jdbc workflow
 
2 jdbc drivers
2 jdbc drivers2 jdbc drivers
2 jdbc drivers
 
3 jdbc api
3 jdbc api3 jdbc api
3 jdbc api
 
4 jdbc step1
4 jdbc step14 jdbc step1
4 jdbc step1
 
Dao example
Dao exampleDao example
Dao example
 
Sessionex1
Sessionex1Sessionex1
Sessionex1
 
Internal
InternalInternal
Internal
 
3. elements
3. elements3. elements
3. elements
 
2. attributes
2. attributes2. attributes
2. attributes
 
1 introduction to html
1 introduction to html1 introduction to html
1 introduction to html
 
Headings
HeadingsHeadings
Headings
 
Forms
FormsForms
Forms
 
Css
CssCss
Css
 
Views
ViewsViews
Views
 
Views
ViewsViews
Views
 
Views
ViewsViews
Views
 
Starting jdbc
Starting jdbcStarting jdbc
Starting jdbc
 

Recently uploaded

How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxNikitaBankoti2
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIShubhangi Sonawane
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 

Recently uploaded (20)

How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 

Data types

  • 1. Data types and Literals 1
  • 2. Objectives On completion of this period, you would be able to know • Data types in Java • Literals in Java 2
  • 3. Recap In the previous class we have discussed • White spaces, separators, literals and keywords • Comments in Java 3
  • 4. Data types in Java • Data types in Java are classified into • Primitive types • Non-primitive types • Primitive types are also known as simple data types • A primitive type is predefined by the language • Primitive types are further classified into • Numeric types • Non-numeric types 4
  • 5. Data types in Java • Non-primitive types are also known as reference types • Non-primitive types are • Classes • Interfaces • Arrays 5
  • 6. The classification of data types in Java Data types in Java Primitive Non-primitive Numeric Non-numeric classe Arrays s integer char Interface Floating point Boolea n Fig. 6.1 Data types in Java 6
  • 7. Data types • Primitive Java data types can be grouped into • integers • floating point numbers • characters • boolean 7
  • 8. Integer types • Java defines four integer types: byte, short, int and long • All these are signed, positive and negative values • Java does not support unsigned types • byte is 8 bit width , short is 16 bit width int is 32 bit width and long is 64 bit width 8
  • 9. byte type • The smallest type is byte • Range from -128 to +128 • Byte variables are declared by use of keyword ‘byte ‘ eg. byte x, y; 9
  • 10. short type • short is a signed 16 bit type. • Its range is from -32,768 to +32,767 • It is probably the least used data type in Java • Keyword used is ‘short’ eg. short x; 10
  • 11. int type • The most commonly used integer data type is int • It has a range of -2,147,483,648 to 2,147,483,647 • Keyword used is ‘int’ eg. int x; 11
  • 12. long type • long is a signed 64 bit type • Useful where an int type is not large enough to hold the desired value • The range of large is quite large • This makes it useful when large, whole numbers are needed • Keyword used is ‘long’ eg. : long seconds; 12
  • 13. floating point types • floating point numbers are also known as real numbers • Are used when fractional components are required • float and double are two kinds of floating point types • Keywords used are ‘float’ and ‘double’ 13
  • 14. Float type • float specify a single precision value that uses 32 bits of storage • float type is useful when you require fractional component, but does not require a large degree of precision eg. float area; 14
  • 15. double type • double uses 64 bits of storage • When you need to maintain accuracy over many iterative calculations or manipulating large valued numbers double is the best choice eg. : double area; 15
  • 16. character type • In Java the data type used to store character is char • char in Java is different from char in C and C++ • Java used Unicode to represent characters • Unicode was selected because it would help in internationalization of Java as a programming language • Java character is 16 bit type. The range of the characters is 0 to 65,536 16
  • 17. boolean type • boolean data type is used to represent logical values that can be either true or false • All relational, conditional and logical operators return boolean values • It used only one bit of storage • Keyword used is ‘boolean’ • eg;. • boolean flag; 17
  • 18. The simple data types in Java • In summary Java defines eight simple types of data. They are • byte • short • int • long • char • float • double • boolean 18
  • 19. Summary • In this class we have discussed • Data types in Java • Literals in Java 19
  • 20. Quiz 1.Which of the following data type can store only two values a) int b) float c) boolean d) All of the above 20
  • 21. Quiz 2.String Literal Enclosed with a) ‘‘ b) ““ c) ** d) All the Above 21
  • 22. Frequently Asked Questions 1. List the different data types available in Java 2. Explain the various data types available in Java 3. List the Literal in Java 4. Explain the Literals in Java 22