JAVA Syllabus
QUESTIONS & ANSWERS

Explain different Data-Types available in JAVA.

In Java, data types are classified into two categories: primitive data types and reference data types.

  1. Primitive Data Types:
    Primitive data types are the most basic data types in Java. There are eight primitive data types available in Java:

    byte:
    It is a 1-byte integer data type, which can hold values from -128 to 127.

    short:
    It is a 2-byte integer data type, which can hold values from -32768 to 32767.

    int:
    It is a 4-byte integer data type, which can hold values from -2147483648 to 2147483647.

    long:
    It is an 8-byte integer data type, which can hold values from -9223372036854775808 to 9223372036854775807.

    float:
    It is a 4-byte floating-point data type, which can hold values with decimal places.

    double:
    It is an 8-byte floating-point data type, which can hold values with decimal places.

    char:
    It is a 2-byte Unicode character data type, which can hold a single character.

    boolean:
    It is a data type with two possible values: true and false.

  2. Reference Data Types:
    Reference data types are the ones that refer to objects. These types do not contain the actual data, but they hold the reference to the memory location where the data is stored. There are four types of reference data types in Java:

    Class Types:
    Class types are the most commonly used reference data types in Java. They refer to objects of a particular class.

    Array Types:
    Array types are reference data types that refer to arrays.

    Interface Types:
    Interface types refer to objects of a particular interface.

    Enum Types:
    Enum types are used to define a fixed set of constants.

03/03/2023, 10:44 am Read : 170 times