What are primitive types in java?

What are primitive types in java?

Java primitive types are not reference types / objects. Java supports 8 primitive data types. Each primitive type has a range of values. They are broadly classified as

- Numeric – which are sub classified as - byte, short, int, long, float and double

- Character - char

- Boolean - boolean.

All numeric data types are signed and there are no unsigned numeric data types. The size of each data type does not change from one architecture to that of another.

Due to this property, Java is so portable. The entire range of values of a specific data type occupies same amount of memory space.

What are primitive types in java?

Data TypeDefault Value (for fields)Size
byte08-bit signed
short016-bit signed
int032-bit signed
long0L64-bit signed
float0.0fsingle-precision 32-bits
double0.0ddouble-precision 64-bit
char'\u0000'16-bit Unicode character
Stringnull
booleanfalsenot precisely defined
Difference between a Vector and an Array. Advantages and disadvantages of both
Vector is a growable and shrinkable where as Array is not...
What is an Exception? Explain by giving an example
What is an Exception? - Exceptions are errors that occur at runtime and disrupt the normal flow of execution of instructions in a program...
Checked Exceptions vs. Unchecked Exceptions
Checked Exceptions vs. Unchecked Exceptions - A checked exception is a subclass of Exception excluding class RuntimeException and its subclasses...
Post your comment