Which of the following is not a primitive data type in java?

Gain Java Knowledge
2 min readMay 22, 2024

Java data types can be divided into two distinct categories: primitive and non-primitive.

There are 8 primitive data types. byte, short, int, long, float, double, boolean, and char.

There are five types of non-primitive data types in Java. They are as follows:

1.Class
2. Object
3. String
4. Array
5. Interface

1. Class and objects:
A class in Java is a user defined data type i.e. it is created by the user. It acts a template to the data which consists of member variables and methods.

An object is the variable of the class, which can access the elements of class i.e. methods and variables.

2. Interface:
An interface is similar to a class however the only difference is that its methods are abstract by default i.e. they do not have body. An interface has only the final variables and method declarations. It is also called a fully abstract class.

3. String:
A string represents a sequence of characters for example “gainjavaknowledge”, “Hello world”, etc. String is the class of Java.

--

--

Gain Java Knowledge

The Java programming language is one of the most popular languages today. Stay up to date with news, certifications, free learning resources and much more.