This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Mock Exam about Entity Class  RSS feed

 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

In the JavaBeat'site, I found a Mock Exam on JPA.
I'm confused with the first question:

1)Which of the following statements are true about the Entity class?

a)Entity class must not have no-arg constructor
b)Entity class must be declared as top level class
c)Interface cannot be Entity
d)Enum can be declared as Entity.

The answer is b and d.
But I think the good answers ar b and c because I found in the spec (2.1) "An enum or interface should not be designated as an entity."

What's your opinion ?
Thanks in advance,

Beno�t
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As for me, the inly possible answer here is C.
All other answers violate rules described by JPA specification.
Answer B is also not correct because Entity may be disposed anywhere in a certain class hierarchy.
 
Benoît de Chateauvieux
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Alex,

Thanks for your answer.
I think that "b)Entity class must be declared as top level class" means that an entity can't be a inner-class.
So, for me, B is right too.
 
Alex Kikhtenko
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, sorry. You're right.

It was my slip-up. Of course B is correct too. I misunderstood the clause "top level class".
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!