SlideShare ist ein Scribd-Unternehmen logo
1 von 14
Downloaden Sie, um offline zu lesen
Basic Datatypes
• Datatypes: int, String, float, short, byte, long,
double, Boolean.
• Datatypes used to create a variables.
• Variables are reserved memory location to store
values.
• When we create variables, we receive some
space in memory.
96.6
200
P1713
Moon
name
regno
amountpercentage
Basic Datatypes
• By assigning different values to variables, we
can store different datatypes.
• 2 datatypes: Primitive, Reference/Object
96.6
200
P1713
Moon
name
regno
amountpercentage
datatype variable_name = value;
datatype variable_name;
variable_name = value;
Basic Datatypes – Primitive Data Types
• Primitive datatypes are predefined by the language and named by a
keywords.
• There are 8 primitive datatypes supported by java.
1. byte
2. short
3. int
4. long
5. float
6. double
7. boolean
8. char
Primitive Data Types ( byte)
• 8 bit signed 2’s complement integer.
(-128)
(0)
• Used to save space in large array.
• 4 times smaller than int.
byte a = 68;
(127)
byte a = -128;
Primitive Data Types ( short)
• 16 bit signed 2’s complement integer.
(-32,768)
(0)
(32,767)
• Used to save space in large array.
• 2 times smaller than int.
short a = 1000;short a = -1000;
Primitive Data Types ( int)
• 32 bit signed 2’s complement integer.
(-2,147,483,648)
(0)
(2,147,483,647)
• Default datatypes for integral values.
• There is a concern about memory.
int a = 1236542;int a = -123648;
Primitive Data Types ( long)
• 64 bit signed 2’s complement integer.
• This type is used when a wider range than int is need
long a = 10486L;long a = -100L;
L is maximum duration of 32
10486L =
-9,223,372,036,854,775,808 to 0L to -9,223,372,036,854,775,807
Primitive Data Types ( float)
• single-precision 32-bit IEEE 754 floating point.
• Used to save memory in large arrays of floating point values.
• Never used for precise values such as currency.
float a = 234.5f;0.0f
Primitive Data Types ( double)
• double-precision 32-bit IEEE 754 floating point.
• generally used as the default data type for decimal values.
• Never used for precise values such as currency.
double a = 234.5;0.0d
Primitive Data Types ( boolean)
• It represents one bit of information.
• 2 possible values: true and false.
• This data type is used for simple flags that
track true/false conditions.
• Default value: false.
boolean a = true;
asign a=10
asign b=20
a=b //false
asign b=b-a
a=b //true
Primitive Data Types ( char)
• 16 bit Unicode character.
• Char data type is used to store any character.
char a = ‘A’;‘u0000’
(0)
‘uffff’
(65,535 inclusive)
Basic Datatypes – Reference Data Types
• Reference variables are created using defined constructors of the classes.
• They are used to access objects.
• Class objects and various type of array variables come under reference datatype
• Default value is null.
Animal a=new Animal();
Animal a=new Animal(0,’asdf’);
Basic Datatypes Notation Character represented
n Newline (0x0a)
r Carriage return (0x0d)
f Formfeed (0x0c)
b Backspace (0x08)
s Space (0x20)
t tab
" Double quote
' Single quote
 backslash
ddd Octal character (ddd)
uxxxx Hexadecimal UNICODE
character (xxxx)
• Few special escape
sequences for String
and char literals

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (13)

Loops and arrays
Loops and arraysLoops and arrays
Loops and arrays
 
Presentation of array
Presentation of arrayPresentation of array
Presentation of array
 
Files and data storage
Files and data storageFiles and data storage
Files and data storage
 
concept of data structure
concept of data structureconcept of data structure
concept of data structure
 
Arrays in C++
Arrays in C++Arrays in C++
Arrays in C++
 
Unit 1 array based implementation
Unit 1  array based implementationUnit 1  array based implementation
Unit 1 array based implementation
 
Dsa unit 1
Dsa unit 1Dsa unit 1
Dsa unit 1
 
Array
ArrayArray
Array
 
Matlab Organizing Data
Matlab Organizing DataMatlab Organizing Data
Matlab Organizing Data
 
National 5 Data Types
National 5 Data TypesNational 5 Data Types
National 5 Data Types
 
Arrays
ArraysArrays
Arrays
 
Chapter 6 java
Chapter 6 javaChapter 6 java
Chapter 6 java
 
Introduction to arrays
Introduction to arraysIntroduction to arrays
Introduction to arrays
 

Ähnlich wie Java basic datatypes

Java basic datatypes
Java basic datatypesJava basic datatypes
Java basic datatypesSoba Arjun
 
5variables in c#
5variables in c#5variables in c#
5variables in c#Sireesh K
 
Programming Fundamentals lecture 6
Programming Fundamentals lecture 6Programming Fundamentals lecture 6
Programming Fundamentals lecture 6REHAN IJAZ
 
Java Tutorial Lab 2
Java Tutorial Lab 2Java Tutorial Lab 2
Java Tutorial Lab 2Berk Soysal
 
java programming basics - part ii
 java programming basics - part ii java programming basics - part ii
java programming basics - part iijyoti_lakhani
 
DATATYPE IN C# CSHARP.net
DATATYPE IN C# CSHARP.netDATATYPE IN C# CSHARP.net
DATATYPE IN C# CSHARP.netSireesh K
 
DConf 2016: Bitpacking Like a Madman by Amaury Sechet
DConf 2016: Bitpacking Like a Madman by Amaury SechetDConf 2016: Bitpacking Like a Madman by Amaury Sechet
DConf 2016: Bitpacking Like a Madman by Amaury SechetAndrei Alexandrescu
 
Data Types in C language
Data Types in C languageData Types in C language
Data Types in C languageAbdulKabeer50
 
Fundamentals of Information Encryption
Fundamentals of Information EncryptionFundamentals of Information Encryption
Fundamentals of Information EncryptionAmna Magzoub
 
Cs1123 3 c++ overview
Cs1123 3 c++ overviewCs1123 3 c++ overview
Cs1123 3 c++ overviewTAlha MAlik
 
Java Data Types and Variables
Java Data Types and VariablesJava Data Types and Variables
Java Data Types and Variablessasi saseenthiran
 
Python Programming | JNTUK | UNIT 1 | Lecture 4
Python Programming | JNTUK | UNIT 1 | Lecture 4Python Programming | JNTUK | UNIT 1 | Lecture 4
Python Programming | JNTUK | UNIT 1 | Lecture 4FabMinds
 

Ähnlich wie Java basic datatypes (20)

Java basic datatypes
Java basic datatypesJava basic datatypes
Java basic datatypes
 
Variable
VariableVariable
Variable
 
5. variables & data types
5. variables & data types5. variables & data types
5. variables & data types
 
5variables in c#
5variables in c#5variables in c#
5variables in c#
 
Programming Fundamentals lecture 6
Programming Fundamentals lecture 6Programming Fundamentals lecture 6
Programming Fundamentals lecture 6
 
Data type
Data typeData type
Data type
 
Java session3
Java session3Java session3
Java session3
 
Lect5
Lect5Lect5
Lect5
 
Java Tutorial Lab 2
Java Tutorial Lab 2Java Tutorial Lab 2
Java Tutorial Lab 2
 
Java - Basic Datatypes.pptx
Java - Basic Datatypes.pptxJava - Basic Datatypes.pptx
Java - Basic Datatypes.pptx
 
Computer programming 2 Lesson 5
Computer programming 2  Lesson 5Computer programming 2  Lesson 5
Computer programming 2 Lesson 5
 
java programming basics - part ii
 java programming basics - part ii java programming basics - part ii
java programming basics - part ii
 
DATATYPE IN C# CSHARP.net
DATATYPE IN C# CSHARP.netDATATYPE IN C# CSHARP.net
DATATYPE IN C# CSHARP.net
 
DConf 2016: Bitpacking Like a Madman by Amaury Sechet
DConf 2016: Bitpacking Like a Madman by Amaury SechetDConf 2016: Bitpacking Like a Madman by Amaury Sechet
DConf 2016: Bitpacking Like a Madman by Amaury Sechet
 
Data Types in C language
Data Types in C languageData Types in C language
Data Types in C language
 
Fundamentals of Information Encryption
Fundamentals of Information EncryptionFundamentals of Information Encryption
Fundamentals of Information Encryption
 
Data types
Data typesData types
Data types
 
Cs1123 3 c++ overview
Cs1123 3 c++ overviewCs1123 3 c++ overview
Cs1123 3 c++ overview
 
Java Data Types and Variables
Java Data Types and VariablesJava Data Types and Variables
Java Data Types and Variables
 
Python Programming | JNTUK | UNIT 1 | Lecture 4
Python Programming | JNTUK | UNIT 1 | Lecture 4Python Programming | JNTUK | UNIT 1 | Lecture 4
Python Programming | JNTUK | UNIT 1 | Lecture 4
 

Mehr von Soba Arjun

Java interview questions
Java interview questionsJava interview questions
Java interview questionsSoba Arjun
 
Java modifiers
Java modifiersJava modifiers
Java modifiersSoba Arjun
 
Java variable types
Java variable typesJava variable types
Java variable typesSoba Arjun
 
Dbms interview questions
Dbms interview questionsDbms interview questions
Dbms interview questionsSoba Arjun
 
C interview questions
C interview questionsC interview questions
C interview questionsSoba Arjun
 
Technical interview questions
Technical interview questionsTechnical interview questions
Technical interview questionsSoba Arjun
 
Php interview questions with answer
Php interview questions with answerPhp interview questions with answer
Php interview questions with answerSoba Arjun
 
Computer Memory Types - Primary Memory - Secondary Memory
Computer Memory Types - Primary Memory - Secondary MemoryComputer Memory Types - Primary Memory - Secondary Memory
Computer Memory Types - Primary Memory - Secondary MemorySoba Arjun
 
Birds sanctuaries
Birds sanctuariesBirds sanctuaries
Birds sanctuariesSoba Arjun
 
Important operating systems
Important operating systemsImportant operating systems
Important operating systemsSoba Arjun
 
Important branches of science
Important branches of scienceImportant branches of science
Important branches of scienceSoba Arjun
 
Important file extensions
Important file extensionsImportant file extensions
Important file extensionsSoba Arjun
 
Java Abstraction
Java AbstractionJava Abstraction
Java AbstractionSoba Arjun
 
Java Polymorphism
Java PolymorphismJava Polymorphism
Java PolymorphismSoba Arjun
 
Java Overriding
Java OverridingJava Overriding
Java OverridingSoba Arjun
 
Java Inner Classes
Java Inner ClassesJava Inner Classes
Java Inner ClassesSoba Arjun
 
java Exception
java Exceptionjava Exception
java ExceptionSoba Arjun
 
java Inheritance
java Inheritancejava Inheritance
java InheritanceSoba Arjun
 
Major tribes of india
Major tribes of indiaMajor tribes of india
Major tribes of indiaSoba Arjun
 

Mehr von Soba Arjun (20)

Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
Java modifiers
Java modifiersJava modifiers
Java modifiers
 
Java variable types
Java variable typesJava variable types
Java variable types
 
Dbms interview questions
Dbms interview questionsDbms interview questions
Dbms interview questions
 
C interview questions
C interview questionsC interview questions
C interview questions
 
Technical interview questions
Technical interview questionsTechnical interview questions
Technical interview questions
 
Php interview questions with answer
Php interview questions with answerPhp interview questions with answer
Php interview questions with answer
 
Computer Memory Types - Primary Memory - Secondary Memory
Computer Memory Types - Primary Memory - Secondary MemoryComputer Memory Types - Primary Memory - Secondary Memory
Computer Memory Types - Primary Memory - Secondary Memory
 
Birds sanctuaries
Birds sanctuariesBirds sanctuaries
Birds sanctuaries
 
Important operating systems
Important operating systemsImportant operating systems
Important operating systems
 
Important branches of science
Important branches of scienceImportant branches of science
Important branches of science
 
Important file extensions
Important file extensionsImportant file extensions
Important file extensions
 
Java Abstraction
Java AbstractionJava Abstraction
Java Abstraction
 
Java Polymorphism
Java PolymorphismJava Polymorphism
Java Polymorphism
 
Java Overriding
Java OverridingJava Overriding
Java Overriding
 
Java Inner Classes
Java Inner ClassesJava Inner Classes
Java Inner Classes
 
java Exception
java Exceptionjava Exception
java Exception
 
Java Methods
Java MethodsJava Methods
Java Methods
 
java Inheritance
java Inheritancejava Inheritance
java Inheritance
 
Major tribes of india
Major tribes of indiaMajor tribes of india
Major tribes of india
 

Kürzlich hochgeladen

ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
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
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
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
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
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
 
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
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
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
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 

Kürzlich hochgeladen (20)

ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
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
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.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
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
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
 
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
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
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
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 

Java basic datatypes

  • 1.
  • 2. Basic Datatypes • Datatypes: int, String, float, short, byte, long, double, Boolean. • Datatypes used to create a variables. • Variables are reserved memory location to store values. • When we create variables, we receive some space in memory. 96.6 200 P1713 Moon name regno amountpercentage
  • 3. Basic Datatypes • By assigning different values to variables, we can store different datatypes. • 2 datatypes: Primitive, Reference/Object 96.6 200 P1713 Moon name regno amountpercentage datatype variable_name = value; datatype variable_name; variable_name = value;
  • 4. Basic Datatypes – Primitive Data Types • Primitive datatypes are predefined by the language and named by a keywords. • There are 8 primitive datatypes supported by java. 1. byte 2. short 3. int 4. long 5. float 6. double 7. boolean 8. char
  • 5. Primitive Data Types ( byte) • 8 bit signed 2’s complement integer. (-128) (0) • Used to save space in large array. • 4 times smaller than int. byte a = 68; (127) byte a = -128;
  • 6. Primitive Data Types ( short) • 16 bit signed 2’s complement integer. (-32,768) (0) (32,767) • Used to save space in large array. • 2 times smaller than int. short a = 1000;short a = -1000;
  • 7. Primitive Data Types ( int) • 32 bit signed 2’s complement integer. (-2,147,483,648) (0) (2,147,483,647) • Default datatypes for integral values. • There is a concern about memory. int a = 1236542;int a = -123648;
  • 8. Primitive Data Types ( long) • 64 bit signed 2’s complement integer. • This type is used when a wider range than int is need long a = 10486L;long a = -100L; L is maximum duration of 32 10486L = -9,223,372,036,854,775,808 to 0L to -9,223,372,036,854,775,807
  • 9. Primitive Data Types ( float) • single-precision 32-bit IEEE 754 floating point. • Used to save memory in large arrays of floating point values. • Never used for precise values such as currency. float a = 234.5f;0.0f
  • 10. Primitive Data Types ( double) • double-precision 32-bit IEEE 754 floating point. • generally used as the default data type for decimal values. • Never used for precise values such as currency. double a = 234.5;0.0d
  • 11. Primitive Data Types ( boolean) • It represents one bit of information. • 2 possible values: true and false. • This data type is used for simple flags that track true/false conditions. • Default value: false. boolean a = true; asign a=10 asign b=20 a=b //false asign b=b-a a=b //true
  • 12. Primitive Data Types ( char) • 16 bit Unicode character. • Char data type is used to store any character. char a = ‘A’;‘u0000’ (0) ‘uffff’ (65,535 inclusive)
  • 13. Basic Datatypes – Reference Data Types • Reference variables are created using defined constructors of the classes. • They are used to access objects. • Class objects and various type of array variables come under reference datatype • Default value is null. Animal a=new Animal(); Animal a=new Animal(0,’asdf’);
  • 14. Basic Datatypes Notation Character represented n Newline (0x0a) r Carriage return (0x0d) f Formfeed (0x0c) b Backspace (0x08) s Space (0x20) t tab " Double quote ' Single quote backslash ddd Octal character (ddd) uxxxx Hexadecimal UNICODE character (xxxx) • Few special escape sequences for String and char literals