111k views
5 votes
A program requires a variable to store an integer value of 3000000000. Which of the following statements can be used?

int bigNumber =
300000000
short bigNumber =3000000000
double bigNumber = 3000000000
byte bigNumber=3000000000
long bigNumber
3000000000​

User Miconda
by
4.1k points

1 Answer

1 vote

The statement that can be used to store an integer value of 3000000000 is:

long bigNumber = 3000000000

The reason for this is that 3000000000 is outside the range of values that can be stored in the int, short, byte, and double data types.

The int data type can store values from -2,147,483,648 to 2,147,483,647, which does not include 3000000000.

The short data type can store values from -32,768 to 32,767, which also does not include 3000000000.

The byte data type can store values from -128 to 127, which is even smaller than the range of the short data type.

The double data type is used to store decimal values with double precision, and cannot be used to store integers.

Therefore, the only data type that can store a value of 3000000000 is the long data type, which can store values from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.

User Taraman
by
2.9k points