Which of the following datatypes occupy the same memory size??
-
long and float
-
int and float
-
long and double
-
byte and short
B,C
Correct answer
Explanation
In Java, int and float both occupy 4 bytes (32 bits) of memory. Similarly, long and double both occupy 8 bytes (64 bits). Option A is wrong because long is 8 bytes while float is 4 bytes. Option D is wrong because byte is 1 byte while short is 2 bytes.