Latest Scala Quiz Questions for Beginners & Experience

Stay updated with the latest technology trends while you're on the move - Join DataFlair's Telegram Channel

1. Latest Scala Quiz Questions

After studied the earlier discussed Scala Quiz you prepared your self for Scala interview. This free online Scala Quiz Questions (Scala MCQ’s), helps you to warm up your Scala knowledge. These free Scala Quiz Questions contains some more tricky & information questions about Scala.
If you wanna revise Scala before this Latest Scala Quiz Questions, refer this link Scala Programming Language.

Scala Quiz Questions

Scala Quiz Questions

Q1. Select the output for the following line of code:
println(40.getClass)

Correct! Wrong!

Q2. What about this one?
println("frankl"||true))

Correct! Wrong!

Q3. What is a higher-order function in Scala?

Correct! Wrong!

Q4. Consider the following list:
var countries=List("brazil", "argentina", "colombia")
What does the following code do to it?
println{
countries.reduceLeft[String]{(c1: String, c2: String)=>
s"$c1, $c2"
}
}

Correct! Wrong!

Q5. Now consider this list:
var rrr= List("ant", "beer", "battered", "cool", "burger")
What will this code do to it? Select what it prints.
rrr.filter {(w: String) =>
w.take(1) == "b"
}.reduceLeft{(a: String, b: String) =>
s"$a $b"
}

Correct! Wrong!

Q6. Select the correct statements about the apply and unapply methods.

Correct! Wrong!

Q7. What does the following piece of code print?
case class PersonData(name: String, age: Int)
val bob1=new PersonData("bob", 99)
val bob2=new PersonData("bob", 99)
println(bob1==bob2)

Correct! Wrong!

Q8. The following statements are true about companion objects and companion classes:

Correct! Wrong!

Q9. Tell us the output of the following snippet of code:
case class Dog(breed: String, age: Int)
val fido= new Dog("lab", 4)
println(fido.toString)

Correct! Wrong!

Q10. What does this code do?
object DoubleUtils{
implicit class Funny(val num: Double, joke: String){
def knockKnock={
s"${num.toString} is here"
}
}
}
import DoubleUtils._
println(3.14.knockKnock)

Correct! Wrong!

Q.11 Select the correct output:
object Whatever{
def speak(something: String)(implicit nice: String)={
println(s"$something $nice")
}
}

implicit val nice= "the walrus"
println{
Whatever.speak("I am")
}
println{
Whatever.speak("I like")("catfood")
}

Correct! Wrong!

Q.12 Select the correct statements from the following:

Correct! Wrong!

Q.13 What does the following code print?
trait Diva{
var attitude= "subjective"
}
var arianaGrand= new Diva
println(arianaGrande.attitude)

Correct! Wrong!

Q.14 Slect the correct statements from the following:

Correct! Wrong!

Q.15 Consider the following string.
val s= "(888) 333-4444"
How would you replace all digit with the letter 'x'?

Correct! Wrong!

Q.16 Which of the following is not a way to make an executable Scala program?

Correct! Wrong!

Q.17 One of the following is not a kind of Scala identifier. Selct the one.

Correct! Wrong!

Q.18 Which of the following is a type of literal in Scala?

Correct! Wrong!

Q.19 Select a regular expression from the options that will parse out the number from the following string: "Milton Friedman died at 94 years of age."

Correct! Wrong!

Q. 20 Select the correct statements about Array and ArrayBuffer.

Correct! Wrong!

Q.21 The following code complies:
class Complex(real:Double,imaginary:Double){
def re()=real
def im()=imaginary
}

Correct! Wrong!

Q.22 Does this code compile successfully? Does it print anything?
 def sad="meow"
val catCry=sad
println(catCry())

Correct! Wrong!

Q.23 Select the correct output for the code:
val arr=Array(2,3,4)
arr.update(1,5)

Correct! Wrong!

Q.24 What is the output of the following code?
class User(n:String){
val name:String=n
}
var u=new User(n="Frankl")
println(u.name)

Correct! Wrong!

Q.25 What does the variable x hold in the following code:
var x,y,z=(1,2,3)

Correct! Wrong!

Have you enjoyed the Scala Quiz? Share your feedback with us!

You can prepare for Scala interview – refer this Scala Interview Questions

2 Responses

  1. JAYACHANDRA says:

    Q4. Consider the following list:

    var countries=List(“brazil”, “argentina”, “colombia”)

    What does the following code do to it?

    Prints only brazil and argentina

    please check once

    • DataFlair Team says:

      Hello Jayachandra,
      Thanks for the query, our experts cross-checked the Q.4 of this Scala Quiz and it seems correct. Try running it elsewhere.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.