Java Data Types

Ace your homework & exams now with Quizwiz!

Non-primitive data types

data types that include Classes, Interfaces, and Arrays.

Primitive data types

data types that include boolean, char, byte, short, int, long, float and double.

Int Data Type

- It is a 32-bit signed two's complement integer. Its value-range lies between - 2,147,483,648 (-2^31) to 2,147,483,647 (2^31 -1) (inclusive). Its minimum value is - 2,147,483,648and maximum value is 2,147,483,647. Its default value is 0. - It is generally used as a default data type for integral values unless if there is no problem about memory.

Long Data Type

- It is a 64-bit two's complement integer. Its value-range lies between -9,223,372,036,854,775,808(-2^63) to 9,223,372,036,854,775,807(2^63 -1)(inclusive). Its minimum value is - 9,223,372,036,854,775,808and maximum value is 9,223,372,036,854,775,807. Its default value is 0. - it is used when you need a range of values more than those provided by int.

Double Data Type

- It is a double-precision 64-bit IEEE 754 floating point. Its value range is unlimited. The ____ data type is generally used for decimal values just like float. - This data type also should never be used for precise values, such as currency. Its default value is 0.0d.

Float Data Type

- It is a single-precision 32-bit IEEE 754 floating point. Its value range is unlimited. It is recommended to use a _____ (instead of double) if you need to save memory in large arrays of floating point numbers. - This data types should never be used for precise values, such as currency. Its default value is 0.0F.

Short Data Type

- It is an 16-bit signed two's complement integer. - Its value-range lies between -32,768 to 32,767 (inclusive). Its minimum value is -32,768 and maximum value is 32,767. Its default value is 0. - can also be used to save memory just like byte data type. A short data type is 2 times smaller than an integer.

Byte Data Type

- It is an 8-bit signed two's complement integer. - Its value-range lies between -128 to 127 (inclusive). Its minimum value is -128 and maximum value is 127. Its default value is 0. - It is used to save memory in large arrays where the memory savings is most required. It saves space because a byte is 4 times smaller than an integer. It can also be used in place of "int" data type.

Char Data Type

-It is a single 16-bit Unicode character. Its value-range lies between '\u0000' (or 0) to '\uffff' (or 65,535 inclusive). -This data type is used to store characters.

true. Primitive data types & Non-primitive data types

There are two types of data types in Java. true or false

- boolean data type - byte data type - char data type - short data type - int data type - long data type - float data type - double data type

What are the 8 types of primitive data types

Data types

specify the different sizes and values that can be stored in the variable.

Boolean Data Type

this data type is used to store only two possible values: true and false. This data type is used for simple flags that track true/false conditions.


Related study sets

Graphs and equations of motion - 3.4

View Set

Student Government Association Constitution Trivia

View Set

College Credit English Semester 2 Exam

View Set

CHAPTER 10 - ANKLE AND FOOT JOINTS

View Set