Identify the correct statements about the primary key of an entity:
a) It cannot consist of multiple fields.
b) It must be serializable and must also override equals and hashCode methods appropriately.
c) In an entity class hierarchy, the class for which the primary key has been defined must be the
root class of the hierarchy and must be an Entity class.
d) If property-based access is used, the properties of the primary key class must be public or protected.
e) The primary key class must be public or default accessed and must have a public no-arg constructor.
The correct answers are a) and d).
The explanation for b) being correct is: "The primary key class ..."
In my opinion b) isn't correct because the question asks for a "primary key" and not for a
primary key class or a composite primary key. So
@Id int id;
is a valid primary key and since id is of primitive type it hasn't even an equals or hashCode
method that could be overriden.
sorry for causing confusion. I meant "The correct answers given by enthuware are b) and d)".
Amandeep is right: There are indeed many such questions/answers in enthuware that are
not quite correct or at least discussable. It's best to choose the most likely answer and
hope for questions with unique answers in the real exam.