MSK Institute • Shikohabad
Loading Page Content...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Connecting serverPlease wait...
💻 Practical Labs🚀 Free Demo📜 Verified Certificates
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Java is a strongly-typed language. Data is stored either as primitive types (allocated directly on the stack) or reference types (objects allocated on the heap). Java specifies exactly 8 primitive types, with identical bit sizes across all platforms.
| Type | Size | Range | Default Value | Example Literal |
|---|---|---|---|---|
byte | 1 byte (8 bits) | -128 to 127 | 0 | byte b = 100; |
short | 2 bytes (16 bits) | -32,768 to 32,767 | 0 | short s = 25000; |
int | 4 bytes (32 bits) | -2.14B to +2.14B | 0 | int count = 450000; |
long | 8 bytes (64 bits) | -9 quintillion to +9 quintillion | 0L | long pop = 8000000000L; (Requires L) |
float | 4 bytes (32 bits) | ~7 decimal digits | 0.0f | float temp = 98.6f; (Requires f) |
double | 8 bytes (64 bits) | ~15 decimal digits | 0.0d | double fee = 4999.75; |
char | 2 bytes (16 bits) | 0 to 65,535 (Unicode UTF-16) | '\u0000' | char grade = 'A'; |
boolean | JVM-dependent | true or false | false | boolean active = true; |
Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
Test your understanding of this lesson with 1 questions. Each question has one correct answer.