Explain the various Primitive Types of Java.
Advertisements
प्रश्न
Explain the various Primitive Types of Java.
स्पष्ट करा
Advertisements
उत्तर
- Integer Data Types: Integer data types are used to store whole numbers without decimal points. Java provides four integer data types:
- byte: It is an 8-bit data type that occupies 1 byte of memory and stores small integer values.
- short: It is a 16-bit data type that occupies 2 bytes of memory and stores integer values.
- int: It is a 32-bit data type that occupies 4 bytes of memory and is commonly used to store whole numbers.
- long: It is a 64-bit data type that occupies 8 bytes of memory and is used to store large integer values.
- Floating-Point Data Types: Floating-point data types are used to store numbers containing decimal points. Java provides two floating-point data types:
- float: It is a 32-bit data type that occupies 4 bytes of memory and stores decimal values with approximately 6–7 significant digits of precision.
- double: It is a 64-bit data type that occupies 8 bytes of memory and stores decimal values with approximately 15–16 significant digits of precision.
- Character Data Type: The
chardata type is used to store a single Unicode character. It occupies 2 bytes (16 bits) of memory and can represent letters, digits and special symbols. - Boolean Data Type: The
booleandata type is used to store logical values, which can be eithertrueorfalse. It is mainly used in conditional statements and decision-making operations.
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
