1.
One is a Java object, the other is a Scala object.
2.
clone() will copy class structures but not the data, while copy() will also copy data into new objects.
3.
There is no difference.
4.
copy() allows you to change values during the copying process; clone() does not.
Q 1 / 52
scala val m1 = Map("a"->1,"b"->2,"c"->3) m1("a")
1.
a
2.
2
3.
b
4.
1
Q 2 / 52
1.
monads
2.
literal functions
3.
partially applied functions
4.
parallel collections
Q 3 / 52
1.
ArgumentExceptions
2.
AssertionException
3.
DiagrammedAssertions
4.
JUnit
Q 4 / 52
1.
Array
2.
ImmutableCollection
3.
List
4.
Tuple
Q 5 / 52
myfnc: ()Unit
1.
The function has no side effects.
2.
The function takes no parameters.
3.
The function returns no value.
4.
Returning unit types to the function is a closures.
Q 6 / 52
1.
hexadecimal
2.
short
3.
floating point
4.
long
Q 7 / 52
1.
`List[(String, String)]`
2.
`List[(Array, Array)]`
3.
`List[(Collection, Collection)]`
4.
`List`
Q 8 / 52
val x = (1234, "Active")
1.
List
2.
Map
3.
Tuple
4.
Array
Q 9 / 52
1.
AnyVal
2.
AnyRef
3.
Method
4.
Null
Q 10 / 52
**Example**: yield-body has access to the `e` variable from the for-body scala val a = Array(1, 2, 3, 4, 5) for { e <- a if e > 2 } yield e
1.
Yes and no. It is different depending on the for construct and what it does.
2.
Yes, because the for section does not expose its scope.
3.
No, because for-yield shares the same scope, even though they are within separate curly braces.
4.
Yes, because they are within different curly braces.
Q 11 / 52
Note: ambiguous question, it's not clear what kind of [pattern matching](https://docs.scala-lang.org/tour/pattern-matching.html) is meant here.
1.
using regex
2.
using monads
3.
using string matching
4.
using case classes
Q 12 / 52
val y = List('a','b') val z = y::List('c')
1.
List(a,b,c)
2.
List(List(a, b), c)
3.
List(c,a,b)
4.
List(c,List(a,b))
Q 13 / 52
1.
assert
2.
require
3.
precondition
4.
mustHave
Q 14 / 52
1.
`scala.util.ExceptionHandling`
2.
`scala.Catch.Throw`
3.
`scala.exception.TryFinally`
4.
`scala.util.Try`
Q 15 / 52
val y = (math floor 3.1415 * 2)
1.
short
2.
double
3.
int
4.
bigInt
Q 16 / 52
1.
`%`
2.
`_`
3.
`^`
4.
`-`
Q 17 / 52
**Explanation**: scala val a1 = Array(1, 2, 3) a1{1} = 3 // OK a1 = Array(1, 3, 3) // error: reassignment to val
1.
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.
2.
The 0th element is immutable and cannot be modified. All other elements can be modified.
3.
Yes, val does not make arrays immutable.
4.
No, val makes the array and values of the array immutable.
Q 18 / 52
scala def main () { var a = 0 for (a<-1 until 5){println(a)}
1.
1,2,3,4,5
2.
0,1,2,3,4
3.
1,2,3,4
4.
2,3,4,5
Q 19 / 52
**Note:** singletons may have mutable state
1.
singletons
2.
stationary objects
3.
functional objects
4.
fixed objects
Q 20 / 52
1.
use array named args
2.
use tuple named args
3.
use numbered variables with a _ prefix for example _ 1, _ 2, _ 3
4.
use numbered variables with a $ prefix - for example $1, $2, $3
Q 21 / 52
1.
4
2.
an error
3.
6
4.
3
Q 22 / 52
`val MyFuture = Future {runBackgroundFunction() }`
1.
myFuture.onComplete
2.
myFuture(status)
3.
myFuture.Finished
4.
complete(myFuture)
Q 23 / 52
1.
`%`
2.
`&`
3.
`_`
4.
`-`
Q 24 / 52
1.
polyinheritance
2.
multilevel inheritance
3.
multimode inheritance
4.
hierarchical inheritance
Q 25 / 52
1.
packages
2.
polymorphisms
3.
assertions
4.
traits
Q 26 / 52
1.
If the first else-if does not succeed, then no other else-ifs are tested.
2.
If an else-if does not succeed, then none of the remaining else-if statements or elses will be tested.
3.
All else-if statements are tested in all cases.
4.
If an else-if succeeds, then none of the remaining else-if statements or elses will tested.
Q 27 / 52
1.
recursive methods
2.
currying methods
3.
redefining methods
4.
overriding methods
Q 28 / 52
1.
`_`
2.
`*`
3.
`%`
4.
`&`
Q 29 / 52
scala myClass.foreach(println _)
1.
`myClass.foreach(println ())`
2.
`myClass.foreach(print NIL)`
3.
`myClass.loop(println ())`
4.
`myClass.foreach(x => println(x))`
Q 30 / 52
1.
Immutable objects use less memory than their mutable counterparts.
2.
Immutable objects do not require error handling.
3.
Immutable objects can be used in classes, mutable objects cannot.
4.
Immutable objects are threadsafe.
Q 31 / 52
1.
do-while loop
2.
while loop
3.
for loop
4.
do-until loop
Q 32 / 52
1.
database driver
2.
connection
3.
prepared statement
4.
SQL view
Q 33 / 52
1.
Set
2.
Seq
3.
Hash
4.
Map
Q 34 / 52
1.
use
2.
include
3.
import
4.
assertion
Q 35 / 52
1.
%
2.
DIV
3.
//
4.
/
Q 36 / 52
1.
method
2.
fields and methods
3.
fields, methods, and packages
4.
fields
Q 37 / 52
1.
singleton
2.
assertion
3.
trait
4.
monad
Q 38 / 52
1.
when the function has no side effects
2.
when the function returns a Unit type
3.
when the function is recursive
4.
when the function has side effects
Q 39 / 52
1.
so only methods in the same file can access the field
2.
so only methods in the same package can access the field
3.
so only methods in the same class could access the field
4.
so only methods defined in a Java class can access the field
Q 40 / 52
1.
They do the exact same thing
2.
`==` won't work on objects
3.
`==` cannot be applied to `String`
4.
`==` is a wrapper of `.equals()` and checks for nulls
Q 41 / 52
1.
||
2.
&&
3.
&
4.
%
Q 42 / 52
1.
AltFuture
2.
Future
3.
AltProcess
4.
AltThread
Q 43 / 52
1.
private function
2.
block function
3.
local function
4.
method
Q 44 / 52
1.
multimode method
2.
polymorphic method
3.
closure
4.
collection method
Q 45 / 52
1.
IllegalArgumentException
2.
NumberFormatException
3.
NullPointerExcepetion
4.
MalformedParameterException
Q 46 / 52
1.
a constraint on where a method may be called from
2.
a constraint on values passed to a methode constructor
3.
a class of predifined error messages
4.
a class of Boolean operators
Q 47 / 52
val myNums = (1 to 500).toList list.map(_ + 1)
1.
Change **list.map** to **list.par.map.**
2.
Change **toList** to **toListPar**
3.
Change **val** to **val.par**
4.
Change **toList** to **toParallelList**
Q 48 / 52
1.
a variable defined outside a function
2.
a variable referenced in a function that is not assigned a value by that function
3.
a variable that has a global scope
4.
a variable defined in a class and available to all methods in that class
Q 49 / 52
1.
**==** is wrapper of **.equals()** and checks for Nulls
2.
They do the exact same thing.
3.
== cannot be applied to String.
4.
== won't work on objects
Q 50 / 52
1.
AltThread
2.
AltFuture
3.
AltProcess
4.
Future
Q 51 / 52
scala x= List(1,2,4); x(1)?
1.
(1,2,4)
2.
1
3.
Nil
4.
2
Q 52 / 52