Scala Practice Test | Check Your Scala Knowledge
Check your Scala knowledge by taking this Scala Practice Test.
If you have not seen other scala quizzes, check them now:
Best of Luck for the Scala Practice Test.
0 of 15 Questions completed
Questions:
Information You have already completed the quiz before. Hence you can not start it again.
You must sign in or sign up to start the quiz.
You must first complete the following:
Quiz complete. Results are being recorded.
0 of 15 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 )
Current Review / Skip Answered Correct Incorrect
Question 1 of 15
Select the correct output for the following code: var band={ var name=”sublime” name } println(name)
Question 2 of 15
Choose the correct output for the following code: val x:Option[String]=Some(“hi”) println(x.get)
Question 3 of 15
The following code compiles: class Complex(real:Double,imaginary:Double){ def re()=real def im()=imaginary }
Question 4 of 15
What does this code print? var y:Option[String]=None y.get
Question 5 of 15
Is the following function pure? def change:Unit={ x=x+10 }
Question 6 of 15
Select the correct output for the following code: object Flash{ def superpower=”speed” }
Question 7 of 15
Choose the correct output: object Dog{ def bark=”woof” }
Question 8 of 15
Select the correct output: val numbers=List(11,22,33) var total=0 for(i<-numbers){ total+=i } println(total)
Question 9 of 15
Decide what the following code prints: val odds=List(3,5,7) var result=1 odds.foreach((num:Int)=>result*=num) println(result)
Question 10 of 15
Okay, now try to do this one: val evens=List(2,4,8) println{ evens.foldLeft(0) { (memo: Int, y: Int) => memo+y } }
Question 11 of 15
Select appropriate output: def quadruple(x:Int):Int=x*4 val quadrupleCopy=quadruple _ println(quadrupleCopy(-1))
Question 12 of 15
Which abstraction from functional programming helps us deal with updating complex immutable nested objects?
Question 13 of 15
Choose the correct output: var greeting:Option[String]= Some(“hello”) greeting= Some(7) println(greeting.get)
Question 14 of 15
We do not need to pass these parameters to a method when calling it:
Question 15 of 15
Select the correct output: val cool=Map(“a”->”aaa”, “b”->”bbb”, “a”->”ccc”) println(cool(“a”))
So, this was all about Scala Practice Test. Hope you like our Scala Quiz Questions. Share your query and score with us!
Your 15 seconds will encourage us to work even harder Please share your happy experience on Google
Tags: Free Scala quiz Latest Free Scala Quiz QUiz for Scala Scala MCQ's Scala mock test scala online quiz Scala Online quiz for 2018 Scala Practice Test Scala Quiz
First question: var band={
var name=”sublime”
name
}
It won’t raise an error. It will return sublime.
Hi Mahesh,
Try copying the code and running it the way it is. It will give you the error “not found: value name”. name is out of scope outside the variable band.
Hope, it helps. Please refer our sidebar, for more Scala Quizzes.
Q6 and Q7 I cannot see how the answers to these are both valid? Could you confirm they are correct please.Maybe question needs rewording.They are very similar code samples yet have differing correct answers?Thanks
Hey Patrick,
Thanks for pointing that out. There are some technical issues with Q.6 and Q.7. Our technical team has reviewed it and made the necessary changes.
Now, you can enjoy your learning hurdle-free.