Vidyalelo
Computer Science · Q257

Kotlin Programming MCQ for Competitive Exams, Interviews, and Certifications

Engineering and GATE · Computer Science · question 257

Q257

The code snippet below translates a database user to a model user. Because their names are both User, you must use their fully qualified names, which is cumbersome. You do not have access to either of the imported classes' source code. How can you shorten the type names? import com.tekadept.app.model.User import com.tekadept.app.database.User class UserService fun translateUser(user: com.tekadept.app.database.User): User = com.tekadept.app.model.User(" user.first user.last")

A.
Use import as to change the type name
Answer
B.
Create subtypes with shorter names
C.
Create interfaces with shorter names
D.
Create extension classes with shorter names

Answer: Option A

Solution

Answer: Option A
No explanation is given for this question Let's Discuss on Board