Page 140 - ComputerScience_Class_11
P. 140
The minimum value of a char variable is '\u0000' (Unicode value 0) and the maximum value is '\uffff' (Unicode value
65,535).
Type Size Range Default value Example
byte 1 byte/8 bits -128 to 127 0 byte b = 10;
short 2 bytes/16 bits -32,768 to 32,767 0 short s = 1234;
int 4 bytes/32 bits -2 to 2 -1 0 int i = 123456;
31
31
long 8 bytes/64 bits -2 to 2 -1 0L long l = 123456L;
63
63
float 4 bytes/32 bits -3.4E+38 to 3.4E+38 0.0f float a = 10.67f;
double 8 bytes/64 bits -1.7E+308 to 1.7E+308 0.0 or 0.0d double b = 1234.87674;
char 2 bytes/16 bits 0 to 65,535 \u0000 char c = 'a';
char d = '\u0041';
boolean 1 bit true/false false boolean a = true;
Java uses Unicode character system, which includes ASCII code system and other characters from languages around
the world. To represent Unicode system, 8 bits is not enough to represent all characters, so Java uses 16 bits or 2 bytes
for characters.
Note: A word or a sentence includes more than one character, hence, it is called a String whose size
belongs to the number of characters together held. For example, if the word is “India”, then the size is 2
bytes × 5 characters = 10 bytes.
Non-Primitive Data Types
Non-primitive data types are defined by the user. But they are built on primitive data types, i.e., they basically
concatenate two or more same or different types of primitive data types. The different types of user-defined data
types are String, class, array and interfaces. They are also known as reference data types, composite data types or
user-defined data types.
Non-Primitive
Class Array Interface String
Now, we will discuss the non-primitive data types in detail.
Class
A class is a blueprint or template used to create objects. It defines the data members and methods that will be shared
by all objects created from that class. For example,
class sum
{
// data members
// member methods
}
}
138 Touchpad Computer Science (Ver. 3.0)-XI

