Java MCQ: Which of the following is not a primitive data type in Java?
Answer:
Explanation:
In Java, primitive data types are the basic types that are not objects and hold their values directly in memory. Java has eight primitive data types: byte
, short
, int
, long
, float
, double
, char
, and boolean
. These are the building blocks for data manipulation in Java.
The String
type, however, is not a primitive; it is a class in the Java standard library. While String
is commonly used and has some characteristics similar to primitives, such as creating string literals, it is fundamentally different because it is an object. This allows String
to provide methods for string manipulation, such as length calculation, substring extraction, and more.
Reference links:
https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html