Correct Answer:
List(List(a, b), c)
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
1
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
2
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Future
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
A variable defined outside a function
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Val myNums = (1 to 500).toList
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
A class of predifined error messages
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
IllegalArgumentException
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
&
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
== is a wrapper of .equals() and checks for nulls
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
So only methods in the same class could access the field
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
When the function is recursive
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Trait
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Fields and methods
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
%
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Import
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Hash
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Prepared statement
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Do-while loop
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Immutable objects are threadsafe.
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
MyClass.foreach(x => println(x))
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
*
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Overriding methods
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
If an else-if succeeds, then none of the remaining else-if statements or elses will tested.
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Assertions
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Hierarchical inheritance
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
-
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
MyFuture.onComplete
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
An error
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Use array named args
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Functional objects
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Yes, the reference to the array is immutable, so the location that the array points to is immutable. The values in the array are mutable.
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
_
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Double
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Scala.util.Try
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Assert
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
No, because for-yield shares the same scope, even though they are within separate curly braces.
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Null
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Tuple
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
List
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Floating point
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
The function returns no value.
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Tuple
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
DiagrammedAssertions
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Parallel collections
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Copy() allows you to change values during the copying process; clone() does not.
Note: This Question is unanswered, help us to find answer for this one
Despite using the same code, the different browser and database modules created really are separate modules. This means that each module has its own contents, including any nested classes. Which of the following options is described by the above statements?
Correct Answer:
Tracking module instances
Note: This Question is unanswered, help us to find answer for this one
Regex class is available in the ........................ package.
Correct Answer:
scala.util.matching
Note: This Question is unanswered, help us to find answer for this one
Which of the following is false about Case Class?
Correct Answer:
Case classes can not be initialised
Note: This Question is unanswered, help us to find answer for this one
Choose the correct statement that describes an 'abstract sealed' class?
Correct Answer:
sealed classes can be extended in the same file
Note: This Question is unanswered, help us to find answer for this one
Scala is ................ with Java. The two languages are interoperable with each other.
Correct Answer:
compatible
Note: This Question is unanswered, help us to find answer for this one
Choose the correct statements that describe a Scala Case class?
Correct Answer:
Case class objects are used to implement complex behaviour
Case class instances can be created with a compact syntax
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Which of the following describe using Scala class that is defined in a package object from Java?
Correct Answer:
com/mycompany/test/MyTest.class com/mycompany/test/package.class com/mycompany/test/package$.class
package com.mycompany package object test { val foobar = 42 } package test { class MyTest { def foo(): Int = { 42 } } }
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Often a module is too large to fit comfortably into a single file. When that happens, you can use traits to split a module into separate files. Which of the following is described by the above statement?
Correct Answer:
Splitting modules into traits
Note: This Question is unanswered, help us to find answer for this one
Which of the following is not valid in Scala?
Correct Answer:
lazy var = 10
Note: This Question is unanswered, help us to find answer for this one
When Extractor object is using the match statement, the unapply method will be __ executed.
Correct Answer:
automatically
Note: This Question is unanswered, help us to find answer for this one
Which one of the following options is equivalent to the code below? for { x <- 1 to 10 y <- 1 to 10 } yield (x,y)
Correct Answer:
(1 to 10).flatMap( x => (1 to 10).map(y => (x,y)))
Note: This Question is unanswered, help us to find answer for this one
Which of the following are types of function in Scala?
Correct Answer:
All of the above
Note: This Question is unanswered, help us to find answer for this one
Which of the following statement is about Scala anonymous function?
Correct Answer:
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.
Note: This Question is unanswered, help us to find answer for this one
How to return a value from a scala function?
Correct Answer:
private def checkValu() : Option[Integer] = { if(!list.isEmpty()){ for(value <-list){ val x = list.get(0) } } return (x) }
private def checkValu() : Option[Integer] = { if(!list.isEmpty()){ for(value <-list){ val x = list.get(0) } } return (x) }
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Which of the following one is Accessing scala object fields from java?
Correct Answer:
public class JavaTest { public static void main(String[] args) { int i = TestObject.field(); } }
Note: This Question is unanswered, help us to find answer for this one
Which of the following are functional trio in Scala?
Correct Answer:
filter
map
reduce (foldLeft + foldRight)
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
This trait consists of which of the following methods?
Correct Answer:
Both 1 and 2
Note: This Question is unanswered, help us to find answer for this one
If you want to compare two objects to see if they are equal, you should usually use either ==, or its inverse !=. Which of the following code is true?
Correct Answer:
scala> 1 == 2 res24: Boolean = false scala> 1 != 2 res25: Boolean = true scala> 2 == 2 res26: Boolean = true
Note: This Question is unanswered, help us to find answer for this one
Which of the following are function Literal's in Scala?
Correct Answer:
“World” filter { c => c > 50 }
“World” filter { _ > 50 }
“World” filter ( _ > 50 )
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Choose the correct description for the Scala 'Function Type'?
Correct Answer:
the trait FunctionN
Note: This Question is unanswered, help us to find answer for this one
How to override type() java interface method in a scala class?
Correct Answer:
override def `type` = { ... }
Note: This Question is unanswered, help us to find answer for this one
Which of the following statement is false about Scala?
Correct Answer:
Nil represents null similar in java
Note: This Question is unanswered, help us to find answer for this one
Choose the statement that best describes the line def this(c: String) = this(0, c); for the code fragment below. class ABC(a: Int, b: Int, c: String) { def this(a: Int, c: String) = this(a, 0, c) def this(c: String) = this(0, c); }
Correct Answer:
calls previous auxiliary constructor which calls the primary constructor
Note: This Question is unanswered, help us to find answer for this one
A digital circuit is built from wires and function boxes. Wires carry signals which are transformed by function boxes. Signals will be represented by booleans: true for signal-on and false for signal-off. Which of the following are correct in context of the above statement?
Correct Answer:
All of the above
Note: This Question is unanswered, help us to find answer for this one
Which of the following are the Keywords used in Scala? Check all that apply.
Correct Answer:
Var
Val
Sealed
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
The expression List.apply(1,2,3) is the same as?
Correct Answer:
List(1,2,3)
Note: This Question is unanswered, help us to find answer for this one
Choose the correct output of the following code fragment?
List("Who","is","longest?").foldLeft((0,""))((i,s) => if (i._1 < s.length) (s.length,s) else i )
Correct Answer:
(8,longest?)
Note: This Question is unanswered, help us to find answer for this one
The primary tool Scala gives you to organize your programs is the class. A class is a blueprint for objects. Once you do a class, you can create objects from the class blueprint with the keyword new. Which of the following options is described by the above statements?
Correct Answer:
Classes and types
Note: This Question is unanswered, help us to find answer for this one
When writing the code of a Scala program, you create and interact with objects. To interact with a particular object, you can use a variable that refers to the object. You can do a variable with either a val or var, and assign an object to it. Which of the following option is described by the above statements?
Correct Answer:
Objects and variables
Note: This Question is unanswered, help us to find answer for this one
Which of the following are scala identifiers? Check all that apply.
Correct Answer:
Mixed identifiers
Literal identifiers
Formatted identifiers
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
Choose the best reason why the code fails to compile, for the type hierarchy and expressions as following?
class A { } class B extends A {} class C { } class D extends C { } case class S[T <: A ](a: T*) {} val aa: S[A ] = S[( new B(), new A() ) val cc = S( new D() )
Correct Answer:
In the expression "val cc = S( new D() )" The inferred type arguments [D] do not conform to apply method's type parameter bounds
Note: This Question is unanswered, help us to find answer for this one
Choose the statement that is not correct about Scala's List?
Correct Answer:
List is an abstract class
Note: This Question is unanswered, help us to find answer for this one
Which one of the following is a correct example of using toArray to convert to an array and toList to convert to a list?
Correct Answer:
scala> buf.toArray res13: Array[Int] = Array(12, 15) scala> buf.toList res14: List[Int] = List(12, 15)
Note: This Question is unanswered, help us to find answer for this one
What will be the output for the code fragment?
List(1, 2, 1, 2, 1, 2, 1, 2, 1, 2).drop(1).sliding(1, 2).flatten.toList
Correct Answer:
List(2, 2, 2, 2, 2)
Note: This Question is unanswered, help us to find answer for this one
What will be the output for the code fragment below?
List(Set(1), Set(1,2,3), Set(1, 2)) diff List(Set(1,2,3))
Correct Answer:
List( Set(1), Set(1, 2) )
Note: This Question is unanswered, help us to find answer for this one
Which of the following code snippets correctly represent Type inference on map method of Scala collections?
Correct Answer:
case class MapResult(input: Any, output: Map[_ <: Any, Any]) { override def toString = output.map{ case (k: Any, v: Any) => input + " " + k + " " + v }.mkString("\n") }
Note: This Question is unanswered, help us to find answer for this one
For the code below, Choose the correct statement?
List.tabulate(100)(a => a.toString)
Correct Answer:
Results in an imutable list
Note: This Question is unanswered, help us to find answer for this one
Create an array buffer just like an array, except that you do not need to specify a size. Which of the following implementation will adjust the allocated space automatically?
Correct Answer:
scala> val buf = new ArrayBuffer[Int]() buf: scala.collection.mutable.ArrayBuffer[Int] = ArrayBuffer()
Note: This Question is unanswered, help us to find answer for this one
Which one of the following code example of Scala collection type for filter is correct?
Correct Answer:
scala> List(1, "1") collect { | case x: Int => x | } res0: List[Int] = List(1)
Note: This Question is unanswered, help us to find answer for this one
Which one of the following statement is not correct for trait Iterator?
Correct Answer:
Iterator extends Iterable
Note: This Question is unanswered, help us to find answer for this one
Traits are used to define _ types by specifying the signature of the supported __?
Correct Answer:
object
methods
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
For the code below, which of the following statement is True?
val data = "test" list = List("this", "is", "a", "test") what will be the effect of applying the expression below to the list list.filterNot(elm => elm == data)
Correct Answer:
will return all elements from the list except those which aren't equal to "test"
Note: This Question is unanswered, help us to find answer for this one
Which of the following is false about Monads?
Correct Answer:
Try is a monad with unit(x) = Try(x)
Note: This Question is unanswered, help us to find answer for this one
What is output of the following code?
def main(args: Array[String]) { val capitals = Map("France" -> "Paris", "Japan" -> "Tokyo") println("capitals.get( \"France\" ) : " + capitals.get( "France" )) println("capitals.get( \"India\" ) : " + capitals.get( "India" )) }
Correct Answer:
Some(Paris),None
Note: This Question is unanswered, help us to find answer for this one
Which of the following statement is false for traits?
Correct Answer:
It is not possible to define default implementations for some methods
Note: This Question is unanswered, help us to find answer for this one
Which one is not reserved word in Scala?
Correct Answer:
switch
Note: This Question is unanswered, help us to find answer for this one
Which of the following is Web Frameworks of Scala?
Correct Answer:
The Play framework
Note: This Question is unanswered, help us to find answer for this one
Choose the option that best describes the difference between a var and val definition in Scala?
Correct Answer:
The object assigned to a val cannot be replaced
Note: This Question is unanswered, help us to find answer for this one
In Scala everything is an Object, No ___?
Correct Answer:
primitives
Note: This Question is unanswered, help us to find answer for this one
Choose the best description for the variance expression as following?
A[B <: C]
Correct Answer:
A[B <: C] means that class A can take any class B that is a subclass of C.
Note: This Question is unanswered, help us to find answer for this one
Which of the following is false about Futures and Promises?
Correct Answer:
Futures are non-blocking while promises are blocking
Note: This Question is unanswered, help us to find answer for this one
For the type heirachy defined below, Choose the most correct statement below for the output?
trait A{ def a = 1 } trait X extends A{ override def a = { println("X") super.a } } trait Y extends A{ override def a = { println("Y") super.a } } For the expression val xy = new AnyRef with X with Y xy.a
Correct Answer:
Prints Y then X
Note: This Question is unanswered, help us to find answer for this one
Given the type hierarchy defined below, Choose the most correct statement below?
trait A{ def a = 1 } trait X extends A{ override def a = { println("X") super.a } } trait Y extends A{ override def a = { println("Y") super.a } } For the expression val xy = new AnyRef with X with Y
Correct Answer:
The expression “with X with Y” is an example of the mixin syntax
Note: This Question is unanswered, help us to find answer for this one
For the code below abstract class A { type B <: C abstract class C { def superClassM(b: B): D } class EImpl extends C { def superClassM(b: B): D = { val e = func1(this, b) e } } def func1(b: B, b1: B): D = D(b, b1) case class D(a: B, b: B) } The code produces the following compile error found : EImpl.this.type (with underlying type A.this.EImpl) required: A.this.B val e = func1(this, b) ^
Choose the expression that allows the code to compile
Correct Answer:
type B = C
Note: This Question is unanswered, help us to find answer for this one
For the code below, Choose the correct statement which explains the error?
abstract class A { type B <: C abstract class C { def superClassM(b: B): D } class EImpl extends C { def superClassM(b: B): D = { val e = func1(this, b) e } } def func1(b: B, b1: B): D = D(b, b1) case class D(a: B, b: B) } When complied produces the following error found : EImpl.this.type (with underlying type A.this.EImpl) required: A.this.B val e = func1(this, b) ^
Correct Answer:
B is an abstract type
Note: This Question is unanswered, help us to find answer for this one
Choose the best description that describes the Scala classes 'scala.AnyRef ' and 'scala.AnyVal'?
Correct Answer:
Value classes extend scala.AnyVal and are predefined types, while all other classes are reference classes that extend scala.AnyRef
Note: This Question is unanswered, help us to find answer for this one
What will the result using the following code?
List(None, Some(1), None, Some(2)).flatMap(x => x)
Correct Answer:
List(1,2)
Note: This Question is unanswered, help us to find answer for this one
How can you make a List[String] from a given val x = List[List[String]]?
Correct Answer:
x.flatten
Note: This Question is unanswered, help us to find answer for this one
Which of the following is not valid using List?
Correct Answer:
val list :List[Int] = List() :: 1
Note: This Question is unanswered, help us to find answer for this one
What is the output of the following code?
def main(args: Array[String]) { printMe(c = 4, b = 5, a = 7); def printMe( a:Int, b:Int, c:Int) = { println( a,b,c ); } }
Correct Answer:
7,5,4
Note: This Question is unanswered, help us to find answer for this one
The map method on List (and Seq), transforms each element of a collection based on a function. For example, if we have a List[String] and want to convert it to all lowercase?
Correct Answer:
scala> List("A", "Cat").map(s => s.toLowerCase)
Note: This Question is unanswered, help us to find answer for this one
Choose the statement that is not correct for Scala's mutable.Map?
Correct Answer:
mutable.Map has a withDefaultValue method that returns a default for undefined keys
Note: This Question is unanswered, help us to find answer for this one
Choose the correct output using the code fragment below?
listOfInts.sliding(2).toList
Correct Answer:
List( List(1, 2), List(2, 3) )
Note: This Question is unanswered, help us to find answer for this one
How to groupBy using multiple columns in Scala collections?
Correct Answer:
records.groupBy(record => (record.column1, record.column2, record.column3))
Note: This Question is unanswered, help us to find answer for this one
What is the output of following code?
def main(args: Array[String]) { val x = {print("x");1} lazy val y = {print("y");2} def z = {print("z"); 3} z+y+x+z+y+x }
Correct Answer:
xzyz
Note: This Question is unanswered, help us to find answer for this one
For the code below, Choose the correct statement that describes an issue with the code?
val L = List[String]() for (a <- 1 to 100) { L :+ a.toString }
Correct Answer:
“L:+ a.toString” is returning a new list each time
Note: This Question is unanswered, help us to find answer for this one
What is the output of given code below?
def addInt( a:Int = 5, b:Int = 7 ) : Int = a + b print(addInt(3,7),addInt(3),addInt(),addInt(b=5))
Correct Answer:
10,10,12,10
Note: This Question is unanswered, help us to find answer for this one
What is the output of the following code?
object MatchTest { def matchTest(x: Any): Any = x match { case 1 => "one" case "two" => 2 case y: Int => "scala.Int" } def main(args: Array[String]) { println(matchTest(2)) } }
Correct Answer:
scala.Int
Note: This Question is unanswered, help us to find answer for this one
Choose the statement that is not correct using the code below?
(1 to 10).par map println
Correct Answer:
If you add par you get a parallel collection and operations on it will always be processed in parallel only if more than one system thread is avaiable
Note: This Question is unanswered, help us to find answer for this one
For the code below, Choose the correct statement which shows the output?
var l1 = scala.collection.mutable.MutableList[String]() val l2 = List[String]() for (a <- 1 to 100) { l1 += a.toString } println(l1 .size); for (a <- 1 to 100) { l2 :+ a.toString } println(l2 .size);
Correct Answer:
100 then 0
Note: This Question is unanswered, help us to find answer for this one
Choose the following statement that is not correct for parallel collections?
Correct Answer:
Calling toSeq on a parallel collection will return a serial collection.
Note: This Question is unanswered, help us to find answer for this one
If Seq is a trait then why is var x = Seq(1, 2, 3) legal?
Correct Answer:
You are calling the apply method on the object
Note: This Question is unanswered, help us to find answer for this one
You can convert any collection. to an array or a list. Such conversion requires copying all of the elements of the collection,and thusis slow for large collections. Sometimes you need to do it, though, due to an existing API. Further, many collections only have a few elements anyway, in which case there is only a small speed penalty?
Correct Answer:
Conversion
Note: This Question is unanswered, help us to find answer for this one
Scala provides __ versions of all of its collection types. These versions cannot be changed after they are initialized. You should use them whenever you know a collection should not be changed, so that you do not accidentally change it later?
Correct Answer:
immutable
Note: This Question is unanswered, help us to find answer for this one
For the code below, choose the correct statement which describes the code?
object A extends B with C { def f(x: Any): Any = ??? }
Correct Answer:
Declares an anonymous class that extends both B and C
Note: This Question is unanswered, help us to find answer for this one
What is the best way to “clone” a case class?
Correct Answer:
Use the copy method
Note: This Question is unanswered, help us to find answer for this one
String interpolation allows users to _____ variable references directly in processed string literals?
Correct Answer:
Embed
Note: This Question is unanswered, help us to find answer for this one
Using the following code fragment, Choose the correct statement which solves the error?
class A(n: Int) { var value = n } class B(n: Int) { val value = new A(n) } object Test { class A(n: Int) { var value = n } class B(n: Int) { val value = new A(n) } object Main extends App { val x = new B(5) x.value = 6 } When complied produces the following error Main.scala:7: error: reassignment to val x.value = 6 ^
Correct Answer:
x.value.value = 6
Note: This Question is unanswered, help us to find answer for this one
Choose the statement that is not correct for trait Traversable?
Correct Answer:
Traversible objects can not be infinite
Note: This Question is unanswered, help us to find answer for this one
Read the following code and tell when do Scala functions execute?
Correct Answer:
All of the above
Note: This Question is unanswered, help us to find answer for this one
For the code fragment below, Choose the expression that shows the correct output?
object Main extends App { val adder = new Adder(2) System.out.println(adder.apply(4)) } class Adder(x: Int) { var y = 5 def apply(y: Int) = x + y }
Correct Answer:
6
Note: This Question is unanswered, help us to find answer for this one
Choose the statement that best describe's the Scala 'apply' function?
Correct Answer:
When you give parameters directly to an object then you you pass these parameters to the apply function of that object
Note: This Question is unanswered, help us to find answer for this one
Which of the following is false for Scala?
Correct Answer:
Scala is pure functional
Note: This Question is unanswered, help us to find answer for this one
For the code fragment below choose the correct statement?
val aa = bb filter (x => x % 2 == 0)
Correct Answer:
aa will be a new collection, while bb will still be the same as before
Note: This Question is unanswered, help us to find answer for this one
For the code fragment below
object Main extends App { def mySum[T <: Number](as: T*): Double = as.foldLeft(0d)(_ + _.doubleValue) implicit def intToInteger(n: Int): Integer = new Integer(n.toInt) var r = mySum(2, 3) }
When complied produces the following error, Choose the correct statement which solves the error when you remove the line implicit def intToInteger(n: Int): Integer = new Integer(n.toInt) Main.scala:4: error: inferred type arguments [Int] do not conform to method mySum's type parameter bounds [T <: Number] var r = mySum(2, 3) ^
Correct Answer:
def mySum[T <% Number](as: T*): Double = as.foldLeft(0d)(_ + _.doubleValue)
Note: This Question is unanswered, help us to find answer for this one
For the code fragment below, Choose the expression that shows the correct output?
object Main extends App { val adder = new Adder(2) System.out.println(adder.apply(4)) var a = new Adder(4) System.out.println(a.applyObj()) } class Adder(x: Int) { var y = 5 def apply(y: Int) = x + y def applyObj() = x + y }
Correct Answer:
6 then 9
Note: This Question is unanswered, help us to find answer for this one
Which of the following is true for Objects, Traits and Classes?
Correct Answer:
To create a program you should use main method in class
Note: This Question is unanswered, help us to find answer for this one
Which of the following code statement is correct, Using scala object inside java?
Correct Answer:
java.util.List
Note: This Question is unanswered, help us to find answer for this one
Choose the correct description for both expressions, for the two expressions as following? expression 1 def m1(i:Int)=i+2 expression 2 (i:Int)=>i+2
Correct Answer:
expression 1 is a method
Note: This Question is unanswered, help us to find answer for this one
How do you provide overloaded constructors in Scala?
Correct Answer:
Use the “this” keyword like def this(...
Note: This Question is unanswered, help us to find answer for this one
For the code below, Choose the best statement to describe this error?
class A(n: Int) { var value = n } class B(n: Int) { val value = new A(n) } object Test { def main(args: Array[String]) { val x = new B(5) x = new B(6) } } Main.scala:7: error: reassignment to val x = new B(6) ^
Correct Answer:
I can not replace the object created on the line above B(6) with this new one.
Note: This Question is unanswered, help us to find answer for this one
Which one of the following about functional combinators is false?
Correct Answer:
find returns the all elements of a collection that matches a predicate function
Note: This Question is unanswered, help us to find answer for this one
Using the code fragment below, Choose the correct statement which explains the error?
object Main extends App { def mySum[T <: Number](as: T*): Double = as.foldLeft(0d)(_ + _.doubleValue) implicit def intToInteger(n: Int): Integer = new Integer(n.toInt) var r = mySum(2, 3) } When complied produces the following error Main.scala:4: error: inferred type arguments [Int] do not conform to method mySum's type parameter bounds [T <: Number] var r = mySum(2, 3) ^
Correct Answer:
[T <: Number] type bounds means that T must be a subtype of Number
Note: This Question is unanswered, help us to find answer for this one
Which of the following statement is false about the functions in Scala?
Correct Answer:
It is possible to define def add(x:Int, y:Int) = x + y as def add(x:Int) (y:Int) = x + y c ) Following code gives compile error
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
False
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
2
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Environment
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Class[Unit]
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Kojo
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
an abstract class
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
i++
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
1
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Case classes are always immutable.
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
scala.Nothing is derived from Option[+A]
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Default definitions for the methods "equals" and "hashCode" are not provided
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
x eq y
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Only if the method expects a single parameter.
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
`lazy var` is not supported by Scala
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
8
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
A procedure type definition
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
It won't compile
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
No
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Any
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
True
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
List is a proxy for java.util.ArrayList
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
public int $plus(int a)
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
The case set must be exhaustive
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
False
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
scala.AnyRef
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
"scalac"
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Objects
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
A singleton object
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
All of these choices describe Scala
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
"void"
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Interface
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
False
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Yes, but it is not idiomatic Scala and therefor discouraged.
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
True
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
An object-functional language that supports functional programming constructs
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
A MatchError would be thrown.
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
A guard
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
True
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
An Iterator is a stream of incoming items where advancing to the next item consumes the current item
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Higher-order functions are functions that take other functions as parameters.
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
An implicit conversion converts the java.lang.String into a scala.collection.immutable.StringOps, which supports a length method.
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
List(5,7,9)
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
A placeholder
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
False
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
a Tuple with Arity 2
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Type bound
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Subtype, ad-hoc and parametric polymorphism
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
~
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Super-class
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
List[AnyVal]
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
When applying the function, you do not pass in arguments for all of the parameters defined by the function, but only for some of them, leaving the remaining ones blank
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
The next element in the list
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Case classes as sealed and therefor cannot be extended
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
By Value
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Parameters
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Data-binding
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
List()
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
Partly at the compiler level. The compiler will try and unwind the recursive call into a loop.
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
A type parameter which is allowed to vary down as the class is subtyped.
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
All types except the value types descend from AnyRef
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
The "accumulator," which is the initial value for `a`
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
List(1,2,3) :+ 5
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
private[examplepackage] def foo = {...}
Note: This Question is unanswered, help us to find answer for this one
Correct Answer:
"_"
Note: This Question is unanswered, help us to find answer for this one
Scala MCQs | Topic-wise