0% found this document useful (0 votes)
0 views

3 Lesson Concept of Data Types in Java

The document explains the concept of tokens in programming, detailing types such as literals, identifiers, punctuators, and operators. It categorizes literals into integer, real, character, and string types, and discusses the importance of selecting appropriate data types in Java, including primitive and non-primitive types. Additionally, it covers type conversion, distinguishing between implicit and explicit conversions, and provides a question bank for further understanding.

Uploaded by

Kuntal Ware
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

3 Lesson Concept of Data Types in Java

The document explains the concept of tokens in programming, detailing types such as literals, identifiers, punctuators, and operators. It categorizes literals into integer, real, character, and string types, and discusses the importance of selecting appropriate data types in Java, including primitive and non-primitive types. Additionally, it covers type conversion, distinguishing between implicit and explicit conversions, and provides a question bank for further understanding.

Uploaded by

Kuntal Ware
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 34

Values

And
Types
What are
Tokens ?
 Each individual
character as well as
punctuation marks used
in statement / sentence
is known as Token. .

 In fact every unit that


makes a statement /
Types Of Token
Literals

Identifie
rs
Tokens
Punctuat
ors

Operator
s
What are
Literals ?
 Literals are
constants.

 Constants means
fixed data value (i.e.:
which do not change).

 While writing any


program , there are
Intege
r

Real
Literals
Charact
er

String
Integer
Literals
 Numbers which are
represented without
decimal point are integer
literals.

 These are the whole


numbers having positive
Real Literals
 Numbers which are
represented with decimal
point are real literals.

 These are floating-point


constants.
Character
 TheLiterals
constants ,which
are alphanumeric in
nature are called
character literals.

 All alphabets (upper /


lower
String Literals
 String is a set of
alphanumeric characters.

 A group of characters
enclosed within a pair of
opening & closing double
quotes is known as string
What
are
Punctuators
 Punctuators are the
punctuation signs used
as special characters in
Java.

 They are use to


separate sentences and
parts of sentences, and
 Examples : -

. (full stop)
(Underline)
? (Question mark)
What
are
Separators
 The special
characters , which are
used to separate the
characters or variables
are called as
separators.
What
are
Identifiers
 Identifiers are called
as variables in Java.

 A variable is a named
memory location ,which
contains a value.

 The value of a
variable can change
Integer
Numeric
Types
Floating

Variables
Charact
er
Non-
Numeric
Types
String
 Integer Type :
• It holds all whole
numbers having positive
or negative values.
• The data type (int ) is
used with the variable to
int a ;
declare it.
data type
Variable to store an integer type valu
 Floating Type :
• It stores all real
numbers (decimal
numbers).
• The data type (float) is
used withfloatthemvariable to
;
declare it.
data type
Variable to store a floating type value
 Character Type :
• It holds only one
character
(alphabet ,digit, special
characters).
• The data type (char) is
char
p ;
used with the variable to
declare
data type
it.
Variable to store a character
 String Type :
• It stores more than one
character
(word ,sentence ,paragra
ph).
• The data type (String)
String
p ;
is used with the variable
to declare it.
data type
Variable to store a string
Data Types
in
Java
 In Java ,we have to deal
with various types of
data ,hence it becomes
necessary for a
programmer to select
appropriate data type
according to data taken.

 Data can be of many


types like numbers,
Data
Types
Non-Primitive
Primitive Types
Types

Classe Interfa
Arrays
s ce
Numeri Non-
c Numeric
Types Types

Intege Floati
Characte Boolea String
rs ng
rs n s
 Primitive data types
• These are also called as
Basic Data Types.
• They are predefined or
built-in in nature .
• E.g. : byte , int , long ,
float , double , char , short ,
boolean .

 Non-Primitive data types


Type Conversion

When you are


dealing with the different
data types in an
expression, the result may
be obtained in any form of
data types. This type of
conversion is called “Type
Type Conversion

Implicit Type Explicit Type


 Implicit Type

• In expression when the


data type of the result
gets converted
automatically into its
higher type ,this type of
conversion is called as
‘Implicit Type’ conversion.
•Example :-
int a;
float b;
float c;
c = a +
b
int flo
at
flo
 Explicit Type

• In some cases ,the


required data type
depends upon the User’s
choice but not dependent
on system. The User
forces the system to get
back into the desired data
type, known as ‘Explicit
Question Bank
1) Define a variable.

2) Distinguish between :-
a) Integer and Floating Literal
b) String and Boolean Literal

3) Explain Type casting.

4) What do you understand by Boolean data


type?
What is its default values ?

5) Write down the data type of : Integer ,


Long Integer , A fractional number ,

You might also like