๐Ÿงช Scala framework MCQ Quiz Hub

Scala Multiple-Choice Questions Set 2

Choose a topic to test your knowledge and improve your Scala framework skills

The output of the following block of code is - class Student{ var roll = 43; def printTotal(){ var totalMarks = 500 println(roll) } } object MyClass{ def main(args:Array[String]) { var s1 = new Student println(s1.totalMarks) } }





โœ… Correct Answer: 3

Which is valid to method to increase value of variable by one?





โœ… Correct Answer: 3

The output of the following code is - object MyClass{ def main(args:Array[String]) { var a = 43 a += 4 a -= 3 println(a) } }





โœ… Correct Answer: 2

Ignored variables are used to -





โœ… Correct Answer: 1

Wildcard patterns (_) is used to -





โœ… Correct Answer: 3

The following code statement will - import java.util._





โœ… Correct Answer: 3

What are expressions in Scala?





โœ… Correct Answer: 1

Conditional statement in Scala executes a block of code based on some conditional value?





โœ… Correct Answer: 1

Which of these is not a conditional statement in Scala?





โœ… Correct Answer: 3

The output of the code block of code is - var myNumber = 5 ; if(myNumber > 20) print("A"); else if(myNumber > 15) print("B"); else print("C");





โœ… Correct Answer: 3

The do-while loop in Scala is -





โœ… Correct Answer: 3

The for loop in Scala is -





โœ… Correct Answer: 1

The output of the following block of code is - var myVar = 12; print(myVar); while(myVar <= 10){ print("*"); myVar += 2; }





โœ… Correct Answer: 1

2-D structures in Scala can be looped using -





โœ… Correct Answer: 1

Output of the following block of code - for(i <- 1 to 2){ for(j <- 1 to 2) print("(" + i + "," + j + ") ") }





โœ… Correct Answer: 2

The break statement in Scala is imported using -





โœ… Correct Answer: 3

Yield in Scala is used to -





โœ… Correct Answer: 4

Can there be multiple counters in a for loop in Scala?





โœ… Correct Answer: 1

To create a loop breakable in Scala, do we need to enclose it?





โœ… Correct Answer: 2

The default parameters are used when -





โœ… Correct Answer: 1

The output of the following block of code is - object Demo { def welcome( a: Int = 54, b: Int = 21 ){ println(a + b); } def main(args: Array[String]) { welcome(5); } }





โœ… Correct Answer: 3

Recursion function is -





โœ… Correct Answer: 1

Which of these can be solved using recursion?





โœ… Correct Answer: 3

Method overloading in Scala is?





โœ… Correct Answer: 2

def datatype(x:Float){ println("The parameter is of Float data type") } def datatype(x:Char){ println("The parameter is of Character data type") } def datatype(x: Boolean){ println("The parameter is of Boolean data type") } def main(args: Array[String]) { datatype(4.0f) } }





โœ… Correct Answer: 4

Which statement in Scala is used to create a tail-recursive function -





โœ… Correct Answer: 4

Tail recursion in Scala is -





โœ… Correct Answer: 1

What is the maximum number of parameters a method can accept?





โœ… Correct Answer: 4

Which syntax to pass the variable argument to function in Scala?





โœ… Correct Answer: 3

Can you alter the sequence of parameter passing?





โœ… Correct Answer: 1

The output of the following block of code is - object Demo { def sub( a:Int, b:Int ) = { println( (a-b) ); } def main(args: Array[String]) { sub(b = 5, a = 7); } }





โœ… Correct Answer: 2

Closures in Scala are -





โœ… Correct Answer: 3

The output of the following block of code will be - object myObject { var multiplier = 5; def main(args: Array[String]) { println(calculator(45)); } val calculator = (i:Int) => i * multiplier; }





โœ… Correct Answer: 4

Which of these parts of the declaration are not required in the case of parameter less methods?





โœ… Correct Answer: 4

Which of these ways of invoking a method are valid in Scala?





โœ… Correct Answer: 4

Lambda expression stores the value of -





โœ… Correct Answer: 3

Can Lambda expressions be used on collections in Scala?





โœ… Correct Answer: 1

Ways to define a composite function in Scala are -





โœ… Correct Answer: 4

What is the output of the following block of code - object myObject { def main(args: Array[String]) { println(( div(mul(452)) )) } val mul = (a: Int)=> { a * 100 } val div = (a: Int) =>{ a / 500 } }





โœ… Correct Answer: 3

What is the chopping of string -





โœ… Correct Answer: 2

Unit value in Scala is -





โœ… Correct Answer: 4

Array in Scala is -





โœ… Correct Answer: 3

Which Scala keyword is used to create an array?





โœ… Correct Answer: 3

Correct syntax for creating an array in Scala -





โœ… Correct Answer: 4

Is array mutable in Scala?





โœ… Correct Answer: 2

How to create a mutable array in Scala?





โœ… Correct Answer: 2

Methods which can be used to remove/ delete users from arrayBuffer in Scala?





โœ… Correct Answer: 1

Method used to get the length of array in Scala -





โœ… Correct Answer: 3

List in Scala is -





โœ… Correct Answer: 3

Method used to check if a list is empty in Scala -





โœ… Correct Answer: 1