data type, type casting,constants. data types in java
TRANSCRIPT
Data type , Type Casting ,Constants
DATA TYPES IN JAVA
Data types in javaEvery variable declared in a Java program is having the data type. Data type specifies the size and type of values that a variable can have. Java has a rich set of data types.
Integer Data Type
Real Data Type
Character & Boolean Data Type
• Character :In order to store single character constant in a variable, character data type is used.- minimum value is ‘\u000’=0- maximum value is ‘\uffff’=65535
• Boolean :Boolean data type is used to store two different values. But,values stored inside the boolean type will only be true and false.
Type Casting
What is type casting?
Changing a value from one data type to another data type is known as data type conversion i.e. assigning a value of one type of a variable of another type is known as type casting.
Types of type casting:1. Widening Type Casting (Implicit)2. Narrowing Type Casting ( Explicit)
Widening Type Casting (Implicit)
• If a value of lower size data type converted to a value of higher size data type without loss of information is Implicit casting.
Narrowing Type Casting ( Explicit)
• If a value of higher size data type converted to a value of lower size data type without loss of information is Implicit casting.
MSBTE Question Bank:
Q1 .Write all primitive data type available in java with their storage sizes in bytes.(w-9, s-12)
Q2 . List different data types in java.(s-10)Q3. Give all the primitive data types available in
java with their strorage size in bytes. (s-13) Q4. Explain ‘type casting ‘ with example.(s-11)Q5
. What do you mean by type casting ?when is it needed?(w-12)