Summer Home Work Class IX 2024 (1)
Summer Home Work Class IX 2024 (1)
❖ DATA TYPES IN JAVA: Data type in Java is used to identify data and dictate
the JVM what type of data will be stored in a variable during program execution and
therefore allocates enough space for the variable. Java data types are of two kinds:
⎯ Primitive or Fundamental or Intrinsic data type: The data types which are
independent of any other type, are known as Primitive data types. They are pre-
defined or built-in data types because the system developers of Java have defined
them. Java provides 8 different primitive data types. byte, short, int, long, float,
Integer Primitive Data Type: It is used to store integer data that is numbers
without a decimal point. Java uses 4 integer data types. byte, short, int and long.
Data Type Size Range
point i.e., fractional numbers. float and double are the two Floating Primitive
Java follows the UNICODE system to represent characters. Thus, the size of a
Boolean Primitive Data Type: It is used to represent the two states that a condition
that can evolve in Java. Any condition in Java can either be valid, i.e. true or invalid,
i.e. false.
Statement.
For example,
d = b * b – 4 * a * c;
c is an Arithmetical Statement.
Types of Arithmetical Expressions:
Based on the data types, the arithmetical expression is of two types:
(1) Pure Expression: An Arithmetical expression that uses all its components of
int c = a + b - c;
In the expression above, all its components like a, b and c are integer data type.
Expression.
float f, d;
double s = a + f - d;
Here, a, f, d and s are of different data types. So, it is an Impure Expression.
one form of its data types. Hence, it is needed to convert the various data types into a
single type. Such conversion is termed as Type Conversion. In Java, Type Conversion
automatically converted into the higher most data type available in the expression
without any intervention of the user. This process of type conversion is known as
byte
char
short
int
long
float
double
⎯ Explicit Type Conversion: When the data type gets converted to another data
type after user’s intervention, the type of conversion is known as explicit type
double x = 10.5;
System.out.println(y); // prints 10
The double x is explicitly converted to int y and thus y gets the value 10.