163k views
5 votes
Entities and POJOs μst have a usable public constructor. You can have an empty constructor or a constructor whose parameters match the fields (by name and type).

A) True
B) False

User Romuloux
by
7.7k points

1 Answer

5 votes

Final answer:

Entities and POJOs must have a usable public constructor, either an empty constructor or a constructor whose parameters match the fields by name and type.

Step-by-step explanation:

Entities and POJOs (Plain Old Java Objects) must have a usable public constructor. This means that they either need to have an empty constructor or a constructor whose parameters match the fields in the class, by name and type. This is important because constructors are used to create instances of the class and initialize its fields.

For example, let's say we have a class 'Student' with two fields: 'name' and 'age'. To create a usable constructor for this class, we could have either an empty constructor like 'public Student() {}' or a constructor with parameters 'public Student(String name, int age) {}'. In both cases, the constructor matches the fields of the class.

User Mohamed Abouelnasr
by
8.1k points