0
0
Spring Bootframework~10 mins

DTO vs entity separation benefit in Spring Boot - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a simple DTO class field.

Spring Boot
private [1] name;
Drag options to blanks, or click blank then click option'
Aint
BString
CEntity
DList
Attempts:
3 left
💡 Hint
Common Mistakes
Using entity class type instead of simple data type.
Using numeric types for text fields.
2fill in blank
medium

Complete the code to convert an entity to a DTO in a method.

Spring Boot
return new UserDTO(entity.get[1]());
Drag options to blanks, or click blank then click option'
AId
BList
CDate
DName
Attempts:
3 left
💡 Hint
Common Mistakes
Using getId() when the DTO expects a name.
Using unrelated getters like getDate().
3fill in blank
hard

Fix the error in the DTO constructor parameter type.

Spring Boot
public UserDTO([1] name) { this.name = name; }
Drag options to blanks, or click blank then click option'
AString
BEntity
Cint
DObject
Attempts:
3 left
💡 Hint
Common Mistakes
Using Entity type instead of String.
Using generic Object type.
4fill in blank
hard

Fill both blanks to map entity fields to DTO fields correctly.

Spring Boot
dto.setName(entity.get[1]());
dto.setEmail(entity.get[2]());
Drag options to blanks, or click blank then click option'
AName
BEmail
CId
DDate
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up field names like using getId() instead of getEmail().
Using setters with wrong getter calls.
5fill in blank
hard

Fill all three blanks to create a DTO from entity fields with proper types.

Spring Boot
public record UserDTO([1] name, [2] email, [3] age) {}
Drag options to blanks, or click blank then click option'
AString
Bint
Dlong
Attempts:
3 left
💡 Hint
Common Mistakes
Using long for age when int is sufficient.
Mixing types between name and email.