Examveda
Examveda

What is the size of a float variable in Java?

A. 4 bytes

B. 8 bytes

C. 2 bytes

D. 16 bytes

Answer: Option A

Solution(By Examveda Team)

The correct answer is Option A: 4 bytes.

In Java, a float variable is a single-precision floating-point data type that occupies 4 bytes of memory.

Here's the breakdown:

Option A: 4 bytes - This is the correct size of a float variable in Java, which is a single-precision floating-point type.

Option B: 8 bytes - This size is associated with the double data type, not float. double is a double-precision floating-point type.

Option C: 2 bytes - This size is associated with the char data type, not float. char represents Unicode characters.

Option D: 16 bytes - This size is not standard for any primitive data type in Java.

So, the size of a float variable in Java is 4 bytes.

This Question Belongs to Java Program >> Data Types And Variables

Join The Discussion

Related Questions on Data Types and Variables