Quizzes
Site Language: English
Українська
English
Русский
Programming Tests
Login
Sign Up
Programming Tests
Theory
Snippets
Papers
Landing
Android
Prices
FAQ
Cosmo Story
Terms and Conditions
Privacy Policy
Cookies Policy
Send Feedback
case-classes
:
Content language: English
Русский
There is a case class: case class MailToken(uuid: String, email: String, creationTime: DateTime, isSignUp: Boolean) And we have the class converter for Java code: public class Token { public String uuid; public String email; public DateTime creationTime; public boolean isSignUp; public MailToken toScala() { return # MISSED CODE; } public static Token fromScala(MailToken scalaToken) { Token javaToken = new Token(); javaToken.uuid = scalaToken.uuid(); javaToken.email = scalaToken.email(); javaToken.creationTime = scalaToken.creationTime(); javaToken.isSignUp = scalaToken.isSignUp(); return javaToken; } } Choose all proper options for MISSED CODE in order to convert properly Token to MailToken.
case-classes
case class Key(x: Int, var y: Int) val key = Key(1,2) val someMap = Map(key -> (1,2)) val newKey = key newKey.y = 3 val newMap = someMap + (newKey -> (1,3)) println(newMap(key)) What will be printed into the console?
case-classes
MUST NOT use "var" inside a case class
case-classes
Given following code: case class User(name: String, email: String, age: Int) val userLikeData = ("John", "john@doe.com", 33) Select all correct ways to instantiate User from userLikeData?
case-classes
Given the case class, what will be the result of calling method inside the object accessing private field of case class? class Person(val name: String, private val superheroName: String) //The superhero name is private! object Person { def showMeInnerSecret(x: Person) = x.superheroName } val clark = new Person("Clark Kent", "Superman") val peter = new Person("Peter Parker", "Spider-Man") Person.showMeInnerSecret(clark) Person.showMeInnerSecret(peter)
case-classes
← Prev
1
Next →
Sign Up Now
or
Subscribe for future quizzes