Latest Scala Quiz Questions for Beginners & Experience
Scala course with real-time projects Start Now!!
This free online Scala Quiz Questions (Scala MCQ’s) help you to warm up your Scala knowledge. These free Scala Quiz Questions contains some more tricky & information questions about Scala.
Do not miss the other 3 scala quizzes from the series of 4 scala quizzes:
- Scala Quiz – 1
- Scala Quiz – 2
- Scala Quiz – 3
- Scala Quiz – 4
Quiz Summary
0 of 25 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
0 of 25 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Categories
- Not categorized 0%
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
- Question 1 of 25
1. Question
Select the output for the following line of code:
println(40.getClass)CorrectIncorrect - Question 2 of 25
2. Question
What will be the output for the following line of code:
println(“frankl”||true))CorrectIncorrect - Question 3 of 25
3. Question
What is a higher-order function in Scala?
CorrectIncorrect - Question 4 of 25
4. Question
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″
}
}CorrectIncorrect - Question 5 of 25
5. Question
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”
}CorrectIncorrect - Question 6 of 25
6. Question
Select the correct statements about the apply and unapply methods.
CorrectIncorrect - Question 7 of 25
7. Question
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)CorrectIncorrect - Question 8 of 25
8. Question
The following statements are true about companion objects and companion classes:
CorrectIncorrect - Question 9 of 25
9. Question
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)CorrectIncorrect - Question 10 of 25
10. Question
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)CorrectIncorrect - Question 11 of 25
11. Question
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”)
}CorrectIncorrect - Question 12 of 25
12. Question
Select the correct statements from the following:
CorrectIncorrect - Question 13 of 25
13. Question
What does the following code print?
trait Diva{
var attitude= “subjective”
}
var arianaGrand= new Diva
println(arianaGrande.attitude)CorrectIncorrect - Question 14 of 25
14. Question
Slect the correct statements from the following:
CorrectIncorrect - Question 15 of 25
15. Question
Consider the following string.
val s= “(888) 333-4444”
How would you replace all digit with the letter ‘x’?CorrectIncorrect - Question 16 of 25
16. Question
Which of the following is not a way to make an executable Scala program?
CorrectIncorrect - Question 17 of 25
17. Question
One of the following is not a kind of Scala identifier. Selct the one.
CorrectIncorrect - Question 18 of 25
18. Question
Which of the following is a type of literal in Scala?
CorrectIncorrect - Question 19 of 25
19. Question
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.”
CorrectIncorrect - Question 20 of 25
20. Question
20 Select the correct statements about Array and ArrayBuffer.
CorrectIncorrect - Question 21 of 25
21. Question
The following code complies:
class Complex(real:Double,imaginary:Double){
def re()=real
def im()=imaginary
}CorrectIncorrect - Question 22 of 25
22. Question
Does this code compile successfully? Does it print anything?
def sad=”meow”
val catCry=sad
println(catCry())CorrectIncorrect - Question 23 of 25
23. Question
Select the correct output for the code:
val arr=Array(2,3,4)
arr.update(1,5)CorrectIncorrect - Question 24 of 25
24. Question
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)CorrectIncorrect - Question 25 of 25
25. Question
What does the variable x hold in the following code:
var x,y,z=(1,2,3)CorrectIncorrect
Have you enjoyed the Scala Quiz? Share your feedback and score with us!
Did you like our efforts? If Yes, please give DataFlair 5 Stars on Google
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
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.
hi check the 20 qn, i hope the fst 2 options are correct.
i am fallowing dataflair from almost 2years.
in hive n hadoop quiz and questions if we select wrong answer it shows the link about the explanation of the answer.
but i didnt seen the option in scala and some more quiz.
if we have that option it will be helpfull.