Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (7k points)

I am preparing for a Java interview and can someone please tell me what are user-defined data types in Java?

1 Answer

0 votes
by (13.1k points)

As you are preparing for an interview, when this sort of question is asked in the interview you need to go into detail on this:

Firstly Java is a strongly typed language i.e. before using any data we need to tell the computer what data type is data will be.

In simple words, we need to declare the data type of the variable.

Basically, there are three types of data types: 

  1. Primitive data types

  2. Derived data types

  3. User-defined data types

Primitive data types are the general and fundamental data types that have in Java and those are byte, short, int, long, float, double, char, boolean.

Derived data types are those that are made by using any other data type, for example, arrays.

User-defined data types are those that the user/ programmer himself defines. For example, classes, interfaces.

In very simple words I can say,

int a

Here a is a variable of int data type.

MyClass obj

Here obj is a variable of data type MyClass and we call them to reference variables as they can be used to store the reference to the object of that class.

Want to learn Java? Check out the Java certification from Intellipaat.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...