Latest Scala Interview Questions and Answers

Read Top Scala Interview Questions and Answers Experienced, Freshers for Job Interview Quiz with Solutions.

What is the use of tuples in scala?

Scala tuples combine a fixed number of items together so that they can be passed around as whole. A tuple is immutable and can hold objects with different types, unlike an array or list.

What is function currying in Scala?

Currying is the technique of transforming a function that takes multiple arguments into a function that takes a single argument Many of the same techniques as language like Haskell and LISP are supported by Scala. Function currying is one of the least used and misunderstood one.

What are implicit parameters in Scala?

Implicit parameter is the way that allows parameters of a method to be “found”.  It is similar to default parameters, but it has a different mechanism for finding the “default” value.  The implicit parameter is a parameter to method or constructor that is marked as implicit.  This means if a parameter value is not mentioned then the compiler will search for an “implicit” value defined within a scope.

What is a closure in Scala?

A closure is a function whose return value depends on the value of the variables declared outside the function.

What is Monad in Scala?

A monad is an object that wraps another object. You pass the Monad mini-programs, i.e functions, to perform the data manipulation of the underlying object, instead of manipulating the object directly.  Monad chooses how to apply the program to the underlying object.

What is Scala anonymous function?

In a source code, anonymous functions are called ‘function literals’ and at run time, function literals are instantiated into objects called function values.  Scala provides a relatively easy syntax for defining anonymous functions.

Explain ‘Scala higher order’ functions?

Scala allows the definition of higher order functions.  These are functions that take other functions as parameters, or whose result is a function.  In the following example, apply () function takes another function ‘f’ and a value ‘v’ and applies function to v.


object Test {

def main(args: Array[String]) {

println( apply( layout, 10) )


def apply(f: Int => String, v: Int) = f(v)

def layout[A](x: A) = “[” + x.toString() + “]”


When the above code is compiled and executed, it produces following result.

C:/>scalac Test.scala

C:/>scala Test




What is the difference between var and value?

In scala, you can define a variable using either a, val or var keywords.  The difference between val and var is,  var is much like java declaration, but val is little different.  We cannot change the reference to point to another reference, once the variable is declared using val. The variable defined using var keywords are mutable and can be changed any number of times.

What are option, some and none in scala?

‘Option’ is a Scala generic type that can either be ‘some’ generic value or none.  ‘Queue’ often uses it to represent primitives that may be null.

How do I append to the list?

In scala to append into a list, use “:+” single value

var myList = List.empty[String]

myList :+= “a”

myList :+= “b”

myList :+= “c”

use++ for appending a list

var myList = List.empty[String]

myList ++= List(“a”, “b”, “c”)


How can you format a string?

To format a string, use the .format () method, in scala you can use

Val formatted=  “%s %i”.format (mystring.myInt)

Why scala prefers immutability?

Scala prefers immutability in design and in many cases uses it as default. Immutability can help when dealing with equality issues or concurrent programs.

What are the four types of scala identifiers?

The four types of identifiers are

a)      Alpha numeric identifiers

b)      Operator identifiers

c)       Mixed identifiers

d)      Literal identifiers

What are the different types of Scala literals?

The different types of literals in scala are

a)      Integer literals

b)      Floating point literals

c)       Boolean literals

d)      Symbol literals

e)      Character literals

f)       String literals

g)      Multi-Line strings


Popular posts from this blog

TOP Agile Testing Interview Questions and Answers

Latest Agile Testing Interview Questions and Answers

Most Asked ADO.NET Interview Questions and Answers