Which of the following statements is true?

Options
- The default char data type is a space( ‘ ‘ ) character.
- The default integer data type is ‘int’ and real data type is ‘float’
- The default integer data type is ‘long’ and real data type is ‘float’
- The default integer data type is ‘int’ and real data type is ‘double’


CORRECT ANSWER : The default integer data type is ‘int’ and real data type is ‘double’

Discussion Board
The default integer data type is ‘int’ and real data type is ‘double’

On the basis of the above question we can ignore the options 1 and 3 as in those the data type integer can't be anything but int. Now, the question is in 2 and 4, so the explanation is given below:

Int: Integer is always of 32 bits in java which is four times the size of a byte (i.e. it is made up of 32 bits).

Minimum Value: -2,147,483,648 (2^31)

Maximum Value: 2,147,483,647 (2^31 – 1)

Default Value: 0

Examples:

int x = 150000

int y = -2004320

On the other hand:

Float: is used for any decimal or fractional value. If there is a decimal after the number, it will be classified as a float. Float is made of 32 bits.

The minimum/maximum value of float is not the same as that of the int data type (despite both being made of 32-bits).

Examples:

float x = 2.321

float y = 1.234

Whereas:

Double: Double is made up of 64 bit which is twice the size of a float. It is used for real numbers due to its high range as the real numbers can have higher ranges which float won't support after sometime so double is the right choice for it.
Examples:

double a = 1.245240

double y = 12.2232

Rohit Sharma 07-27-2014 11:56 PM

The default integer data type is ‘int’ and real data type is ‘double’

For the Statement "The default integer data type is ‘int’ and real data type is ‘double’", Can you please explain in detail with an Example, on what basis is this statement true

Soujanya D 12-13-2013 09:46 AM

Write your comments


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)


Advertisement