Question:

How many basic (primitive) data types are supported in Java?

Show Hint

Java has {8 primitive data types}: byte, short, int, long, float, double, char, and boolean.
  • 2
  • 4
  • 8
  • 16
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation

Step 1: Understanding primitive data types in Java.
In the Java programming language, data types are broadly classified into two main categories: Primitive Data Types and Non-Primitive (Reference) Data Types. Primitive data types are the most basic data types that store simple values directly in memory.
Step 2: List of primitive data types in Java.
Java supports a total of eight primitive data types. These are used to store numbers, characters, and logical values.
The eight primitive data types in Java are:
1. byte – used to store small integers.
2. short – used to store slightly larger integer values.
3. int – the most commonly used integer type.
4. long – used for very large integer values.
5. float – used to store single-precision decimal numbers.
6. double – used to store double-precision decimal numbers.
7. char – used to store a single character.
8. boolean – used to store logical values such as true or false.
Step 3: Evaluating the options.
(A) 2: Incorrect. Java supports more than two primitive types.
(B) 4: Incorrect. Java supports more than four primitive types.
(C) 8: Correct. Java provides eight primitive data types.
(D) 16: Incorrect. The number of primitive types in Java is not sixteen.
Step 4: Conclusion.
Therefore, the number of primitive data types supported in Java is eight.
Final Answer: 8
Was this answer helpful?
0
0