InfySkyWave is working on a Student portal to display the winner for a quiz contest conducted in various batches. Janet is working on the following incomplete code where collections with futures is used to retreive the details in an easier way. (Assume necessary imports have been done.)

object ScalaFutList extends App {
 val f: Future[List[String]] = Future {
   List("Sharon Levin Leon", "Sneha Sweta Sherin", "John Riya Mega")
 }
 //Line 1
 val result = Await.result(f1, Duration(2, "sec"))
 println(result)
}

What code should be placed at Line 1 to get the winners as shown below?

List(Sharon, Sneha, John)

val f1: Future[List[String]] = f.map(x => x.map(y => y.split(" ")(0)))

val f1: Future[List[String]] = f.map(x => x.split(" ")(1))

val f1: Future[List[String]] = f.map(x => x(1))

val f1: Future[List[String]] = f.map(x => x.map(y => y.split(" ")(1)))

Verified Answer
Correct Option - a

To get all Infosys Certified Scala Programmer Exam questions Join Group https://bit.ly/infy_premium_group

We're passionate about offering best placement materials and courses!! A one stop place for Placement Materials. We daily post Offcampus updates and Placement Materials.

Qtr No. 213, New Town Yehlanka Indore 454775

admin@prepflix.in