Data Types

In Java, data type defines a set of values for real numbers, decimal numbers, alphabets, etc. Data types are classified into two types: primitive and non-primitive. The data types that are independent on any other type are known as primitive data types.

In Java, primitive data types are also known as basic or fundamental data types. Some of the primitive data types are int, float, char and boolean. Integers are the whole numbers with a range of values and the range of values are machine dependent. Float data type is used to store fractional numbers. Character type variable can hold a single character. Boolean data type represents the concept of true/false.

In Java, non-primitive data types are created from the basic or fundamental data types. Array, class and interface are the examples of non-primitive data types. Array is a data structure consisting of a group of elements that are accessed by indexing. A class is a group of objects that share common properties and relationships. Object is an entity created according to its class description.

To Access the full content, Please Purchase

  • Q1

    What are the different types of data types supported by Java?

    Marks:1
    Answer:

    There are two data types in Java -

    • Primitive data type and
    • Reference data type

    View Answer
  • Q2

    Define 'constant variable'.

    Marks:1
    Answer:

    A constant variable is a variable whose value does not change during the program execution.

    View Answer
  • Q3

    Explain 'character' data type.

    Marks:1
    Answer:

    Character data type is used to store characters. It can be a number, character or special character and should be enclosed inside single quotes.

    View Answer
  • Q4

    What are numerical data types?

    Marks:1
    Answer:

    Numerical integral type stores whole numbers. Types of numeric integral are int, short, byte and long.

    View Answer
  • Q5

    Define data types.

    Marks:1
    Answer:

    Data types are used to specify the type of data stored by the variable.

    View Answer