Which of the following are the key concepts of Functional Programming a.
Immutability b. Pure functions c. Inheritance d. Referential Transparency .
a,b,d
Functional programming language cannot be an object oriented language too
(True/False)
False
Scala is a pure functional programming language (True/False)
False
You can modify an immutable object once created (Yes/No)
No
Can the following pseudo function be considered a pure function ? function
getMeTimeAdded(arg Integer) = currentTime + Integer
No
For the given statement,
val s = List(1,2,3)
What would be the type of s?
.......List[Int]
Is this a valid expression val f: Int = (x: Int) => x + 1
No
What is the preferred qualifier for defining a variable in Scala.
val
What would be the output of following snippet
val s = List(1,2,3,4)
val t = List(5,6,7,8)
val n = s ++ t
println(n)
.......List(1, 2, 3, 4, 5, 6, 7, 8)
What is the default class List is imported from ?
scala.collection.immutable
What would be the output of following code snippet.
val l = List(1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 5, 5, 8)
println(l.take(3))
.............List(1,1,1)
AnyVal is best type of all primitive data types
True
Scala supports only single inheritance
False
Scalability is an important trait of a functional programming language?
False
Consider the following code snippet
def prnt = {print("scala"); 1}
def fun(a:Int,b: => Int) = print(a)
What will be the output for function call fun(prnt,5)?
............scala1
Is this operation valid
var s = "String 1"
...
...
s = "String 2"
................Yes
Which of the following programming paradigm does Scala support?
All the above
Scala classes can contain static members
False
AnyVal is best type of all primitive data types
False
Which of the following type allows only single instance to exist in global scope
def.....object
Which of the following cannot have a constructor
trait
Functions are first class objects in function programming
True
Consider the following code snippet (a: Int) => a*a. Above code snippet is an
example of
anonymous function
Which one is the correct expression?
val f = (x: Int) => x + 1
Expressions in Scala evaluated using method called?
substitution
Scala compiler will compile the following expression successfully
val s: Int = 5.5
False
Which all frameworks are developed using Scala
Spark
Object keyword is used to define a singleton class in Scala
True
Given the following snippet, what would be the output
val l = List(1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 5, 5, 8)
println(l.drop(10)
................List(3, 5, 5, 8)
Which of the following expression has side effect
var y = 0; def Inc = y=y+1
Which of the following feature in Java resembles trait in Scala
abstract class
Scala can be run only on JVM.
False
Singleton is created in Scala using keyword
Object
In functional programming language functions can be
can only be passed as call by value.....can pass as an argument
Singleton object in Scala can be made executable
by extending App or with the main function
Scala has immutable collections
True
What would be the output of this code
val n = List(1,2,3,4,5)
println(n.map(_ % 2))
............List(1, 0, 1, 0, 1)
Mentioning function return type is optional in Scala
True
Mathematical functions are best implemented in?
functional programming language
Scala is JVM language--True
Following build tools can be used to build Scala projects--All the options
mentioned
Which of the following provides way to multiple inheritances in Scala-trait
Which of the following is a pure functional programming languages-Haskell
Which of the following are member of List-head
Functions can be declared anywhere in Scala-True
What would be the type inferred by Scala compiler for variable salary. val salary =
3000.00----Double
Which of the following feature in Java resembles trait in Scala--interface
1. Scalability is an important trait of a functional programming language?--True
AnyVal is best type of all primitive data types--True
3. Scala supports only single inheritance--True
4. What is the result of the below snippet ?--no match found
5. Case classes can not contain member functions--False