0% found this document useful (0 votes)
19 views2 pages

Java's 8 Primitive Data Types Explained

Java has 8 primitive data types: byte, short, int, long, float, double, char, and boolean, which are stored in stack memory and are faster than objects. Each type has a specific size and range, with default values assigned for each. These types are essential for memory optimization and storing actual values rather than references.

Uploaded by

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

Java's 8 Primitive Data Types Explained

Java has 8 primitive data types: byte, short, int, long, float, double, char, and boolean, which are stored in stack memory and are faster than objects. Each type has a specific size and range, with default values assigned for each. These types are essential for memory optimization and storing actual values rather than references.

Uploaded by

hamidansari8857
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Primitive Data Types in Java (PPL – SPPU)

Java provides 8 primitive data types used to store simple values.

They are stored in stack memory and are faster than objects.

Key Points (Short Notes):

• Primitive types are predefined by Java.

• They store actual values, not references.

• Range and size depend on data type.

• Default values:

- int = 0

- float = 0.0f

- double = 0.0

- boolean = false

- char = '\u0000'

• They help in memory optimization.

1. byte

• Size: 1 byte

• Range: –128 to +127

• Used in large arrays to save memory.

2. short

• Size: 2 bytes

• Range: –32,768 to +32,767

3. int

• Size: 4 bytes

• Default integer type.

4. long

• Size: 8 bytes

• Used for large integer values.

5. float

• Size: 4 bytes
• Single-precision decimal values.

6. double

• Size: 8 bytes

• Double-precision, default for decimals.

7. char

• Size: 2 bytes

• Stores single Unicode character.

8. boolean

• Stores true/false

• Used in conditions & decision making.

Exam Definition:

Java supports 8 primitive data types: byte, short, int, long, float, double, char, and boolean.

You might also like