Data types, keywords, identifiers
in java
•What are identifiers in java.
•What are keywords how & why they are used?
•What are data types in java.
4/10/2019 1Jamsher Bhanbhro(F16CS11)
Identifiers
• Names required for java classes, variables, methods
are called identifiers.
• Can be A-Z or a-z or in mixture(Alphabets).
• Currency character($) can be used as identifier.
• _ underscore can be used.
• Keywords cannot be used as identifier.
• Eg: HelloWorld, Jamsher (may be class names).
• A=3; a=5; z=c; x=y, can be the variables.
• Sum, Sub, Div can be methods.
4/10/2019 Jamsher Bhanbhro(F16CS11) 2
Java Keywords
• Keywords are reserved names for java.
• These can’t be used as identifiers, variables name
etc.
• Abstract: used for class
• Boolean: 0 or 1 true or false
• Break: use to break the statement or the condition
• Char: for data type
• Import, class, switch, case, if else, try, this, throw,
void, return, package etc are the java keywords.
4/10/2019 Jamsher Bhanbhro(F16CS11) 3
Data types in java
• When a variable is assigned a memory it is
assigned by its data types.
• A variable store which type of data is known
as data type.
• There are basically two data types available in
java
1. Primitive data type
2. Non Primitive data type/ Reference data type
4/10/2019 Jamsher Bhanbhro(F16CS11) 4
Primitive data type
• Those data types which are already defined in
the java library is known as Primitive data
type.
• These are built-in or predefined data types.
• Java basically supports 8 predefined data
types.
• Which are byte, short, long, float, double,
Boolean, char, int.
4/10/2019 Jamsher Bhanbhro(F16CS11) 5
1. Integer Data type
• Integer is denoted by int and stores the integer values.
• 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 = 11, int b = 41
4/10/2019 Jamsher Bhanbhro(F16CS11) 6
2. Byte
• 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
• For Example: byte a=11, b=41;
4/10/2019 Jamsher Bhanbhro(F16CS11) 7
3. Float
• Float data-type is a single-precision 32-bit
IEEE 754 floating point.
• 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(f stands for float)
4/10/2019 Jamsher Bhanbhro(F16CS11) 8
4. Short
• Short datatype 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 datatype can also be used to save memory as byte
data type. A short is 2 times smaller than an integer
• Default value is 0
4/10/2019 Jamsher Bhanbhro(F16CS11) 9
5. Long
• Long datatype is a 64-bit signed two's
complement integer
• Minimum value is 9,223,372,036,854,775,808 (-
2^63)
• Maximum value is9,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(L is used for Long)
• Example: long a = 100000L, long b = -200000L
4/10/2019 Jamsher Bhanbhro(F16CS11) 10
6. Char
• char data-type is a single 16-bit Unicode
character.
• Minimum value is 'u0000' (or 0) .
• Maximum value is 'uffff' (or 65,535 inclusive)
.
• Char data-type is used to store any character
• Example: char letterA =‘J‘;
4/10/2019 Jamsher Bhanbhro(F16CS11) 11
7. Boolean
• Boolean data-type represents one bit of
information.
• There are only two possible values: true and
false.
• This data-type is used for simple flags that
track true/false conditions.
• Default value is false .
• Example: boolean one = true, 0=false;
4/10/2019 Jamsher Bhanbhro(F16CS11) 12
8. Double
• double data-type is a double-precision 64-bit
IEEE 754 floating point.
• 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(d for double)
4/10/2019 Jamsher Bhanbhro(F16CS11) 13
Reference data-types
• These are not predefined data-types.
• These are created using defined constructors
of the classes.
• They are used to access the objects
• These are the reference variables
• eg: Jamsher ob=new Jamsher();
4/10/2019 Jamsher Bhanbhro(F16CS11) 14

More Related Content

PPTX
Data types in C
PPTX
Computer programming 2 Lesson 5
PDF
7-Java Language Basics Part1
PPT
Lect 9(pointers) Zaheer Abbas
PPTX
Welcome
PPTX
Data Types - Premetive and Non Premetive
PPSX
Data type
PPTX
Data types in C
Computer programming 2 Lesson 5
7-Java Language Basics Part1
Lect 9(pointers) Zaheer Abbas
Welcome
Data Types - Premetive and Non Premetive
Data type

What's hot (20)

PPTX
Concept Of C++ Data Types
 
PPTX
Data types
PPTX
Variables in C++, data types in c++
PPTX
C PROGRAMMING LANGUAGE
PPTX
data types in C programming
PPT
3 data-types-in-c
PPTX
Data Types
PDF
Data types in Java
PPTX
Computer data type and Terminologies
PDF
Introduction to Text Mining
PPTX
Data types
PPTX
5. variables & data types
PPT
C++ data types
PPTX
Basic Data Types in C++
PPTX
Data types in C language
PPTX
C data types, arrays and structs
PDF
Ijartes v1-i1-002
PPTX
Data types
PPTX
DATATYPE IN C# CSHARP.net
Concept Of C++ Data Types
 
Data types
Variables in C++, data types in c++
C PROGRAMMING LANGUAGE
data types in C programming
3 data-types-in-c
Data Types
Data types in Java
Computer data type and Terminologies
Introduction to Text Mining
Data types
5. variables & data types
C++ data types
Basic Data Types in C++
Data types in C language
C data types, arrays and structs
Ijartes v1-i1-002
Data types
DATATYPE IN C# CSHARP.net
Ad

Similar to Lect5 (20)

PPSX
Java session3
PPTX
01 Java Language And OOP PART I
PPTX
Java - Basic Datatypes.pptx
PPT
C language basics
PPTX
Data types
PPTX
Everything C Data Types_copy_With my_name.pptx
PPTX
java programming basics - part ii
PPTX
Java Tutorial Lab 2
PDF
Java basic datatypes
PPTX
Chapter7-Introduction to Python.pptx
PDF
THE C++ LECTURE 2 ON DATA STRUCTURES OF C++
PPTX
Chapter 2: Elementary Programming
PPTX
Learn C LANGUAGE at ASIT
PPTX
This is a python data types ppt it is used for bca student also
PPTX
introduction to python
PPTX
Module 2 VLSI design and verification by
PDF
Module1PPT.pdf ,introduction to python programing
PPTX
Computer Programming Java Data Types.pptx
PDF
332 ch07
Java session3
01 Java Language And OOP PART I
Java - Basic Datatypes.pptx
C language basics
Data types
Everything C Data Types_copy_With my_name.pptx
java programming basics - part ii
Java Tutorial Lab 2
Java basic datatypes
Chapter7-Introduction to Python.pptx
THE C++ LECTURE 2 ON DATA STRUCTURES OF C++
Chapter 2: Elementary Programming
Learn C LANGUAGE at ASIT
This is a python data types ppt it is used for bca student also
introduction to python
Module 2 VLSI design and verification by
Module1PPT.pdf ,introduction to python programing
Computer Programming Java Data Types.pptx
332 ch07
Ad

More from Jamsher bhanbhro (14)

PDF
Abstraction in Java: Abstract class and Interfaces
PDF
Method, Constructor, Method Overloading, Method Overriding, Inheritance In Java
PPTX
Regular Expressions in Java.
PPTX
Java Arrays and DateTime Functions
PPTX
PPTX
PPTX
PPTX
PPTX
PPTX
PPTX
Compiling and understanding first program in java
PPTX
Introduction to java
PPTX
Caap presentation by me
PPTX
Introduction to parts of Computer(Computer Fundamentals)
Abstraction in Java: Abstract class and Interfaces
Method, Constructor, Method Overloading, Method Overriding, Inheritance In Java
Regular Expressions in Java.
Java Arrays and DateTime Functions
Compiling and understanding first program in java
Introduction to java
Caap presentation by me
Introduction to parts of Computer(Computer Fundamentals)

Recently uploaded (20)

PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
PDF
Trump Administration's workforce development strategy
PDF
What if we spent less time fighting change, and more time building what’s rig...
PDF
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
PDF
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
PDF
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
PPTX
History, Philosophy and sociology of education (1).pptx
PPTX
Introduction to pro and eukaryotes and differences.pptx
PDF
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
PDF
Hazard Identification & Risk Assessment .pdf
PDF
Environmental Education MCQ BD2EE - Share Source.pdf
DOCX
Cambridge-Practice-Tests-for-IELTS-12.docx
PDF
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
PDF
IGGE1 Understanding the Self1234567891011
PDF
advance database management system book.pdf
PDF
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
Trump Administration's workforce development strategy
What if we spent less time fighting change, and more time building what’s rig...
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Weekly quiz Compilation Jan -July 25.pdf
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
Practical Manual AGRO-233 Principles and Practices of Natural Farming
History, Philosophy and sociology of education (1).pptx
Introduction to pro and eukaryotes and differences.pptx
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
Hazard Identification & Risk Assessment .pdf
Environmental Education MCQ BD2EE - Share Source.pdf
Cambridge-Practice-Tests-for-IELTS-12.docx
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
IGGE1 Understanding the Self1234567891011
advance database management system book.pdf
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα

Lect5

  • 1. Data types, keywords, identifiers in java •What are identifiers in java. •What are keywords how & why they are used? •What are data types in java. 4/10/2019 1Jamsher Bhanbhro(F16CS11)
  • 2. Identifiers • Names required for java classes, variables, methods are called identifiers. • Can be A-Z or a-z or in mixture(Alphabets). • Currency character($) can be used as identifier. • _ underscore can be used. • Keywords cannot be used as identifier. • Eg: HelloWorld, Jamsher (may be class names). • A=3; a=5; z=c; x=y, can be the variables. • Sum, Sub, Div can be methods. 4/10/2019 Jamsher Bhanbhro(F16CS11) 2
  • 3. Java Keywords • Keywords are reserved names for java. • These can’t be used as identifiers, variables name etc. • Abstract: used for class • Boolean: 0 or 1 true or false • Break: use to break the statement or the condition • Char: for data type • Import, class, switch, case, if else, try, this, throw, void, return, package etc are the java keywords. 4/10/2019 Jamsher Bhanbhro(F16CS11) 3
  • 4. Data types in java • When a variable is assigned a memory it is assigned by its data types. • A variable store which type of data is known as data type. • There are basically two data types available in java 1. Primitive data type 2. Non Primitive data type/ Reference data type 4/10/2019 Jamsher Bhanbhro(F16CS11) 4
  • 5. Primitive data type • Those data types which are already defined in the java library is known as Primitive data type. • These are built-in or predefined data types. • Java basically supports 8 predefined data types. • Which are byte, short, long, float, double, Boolean, char, int. 4/10/2019 Jamsher Bhanbhro(F16CS11) 5
  • 6. 1. Integer Data type • Integer is denoted by int and stores the integer values. • 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 = 11, int b = 41 4/10/2019 Jamsher Bhanbhro(F16CS11) 6
  • 7. 2. Byte • 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 • For Example: byte a=11, b=41; 4/10/2019 Jamsher Bhanbhro(F16CS11) 7
  • 8. 3. Float • Float data-type is a single-precision 32-bit IEEE 754 floating point. • 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(f stands for float) 4/10/2019 Jamsher Bhanbhro(F16CS11) 8
  • 9. 4. Short • Short datatype 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 datatype can also be used to save memory as byte data type. A short is 2 times smaller than an integer • Default value is 0 4/10/2019 Jamsher Bhanbhro(F16CS11) 9
  • 10. 5. Long • Long datatype is a 64-bit signed two's complement integer • Minimum value is 9,223,372,036,854,775,808 (- 2^63) • Maximum value is9,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(L is used for Long) • Example: long a = 100000L, long b = -200000L 4/10/2019 Jamsher Bhanbhro(F16CS11) 10
  • 11. 6. Char • char data-type is a single 16-bit Unicode character. • Minimum value is 'u0000' (or 0) . • Maximum value is 'uffff' (or 65,535 inclusive) . • Char data-type is used to store any character • Example: char letterA =‘J‘; 4/10/2019 Jamsher Bhanbhro(F16CS11) 11
  • 12. 7. Boolean • Boolean data-type represents one bit of information. • There are only two possible values: true and false. • This data-type is used for simple flags that track true/false conditions. • Default value is false . • Example: boolean one = true, 0=false; 4/10/2019 Jamsher Bhanbhro(F16CS11) 12
  • 13. 8. Double • double data-type is a double-precision 64-bit IEEE 754 floating point. • 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(d for double) 4/10/2019 Jamsher Bhanbhro(F16CS11) 13
  • 14. Reference data-types • These are not predefined data-types. • These are created using defined constructors of the classes. • They are used to access the objects • These are the reference variables • eg: Jamsher ob=new Jamsher(); 4/10/2019 Jamsher Bhanbhro(F16CS11) 14