Skip to content

Commit

Permalink
Update scala-quiz.md (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
GordonGrant authored Aug 14, 2020
1 parent 2bdedb0 commit 20ba22f
Showing 1 changed file with 54 additions and 4 deletions.
58 changes: 54 additions & 4 deletions scala/scala-quiz.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Scala Assessment

#### Q2. What value does this code return?

```
```scala
val m1 = Map("a"->1,"b"->2,"c"->3)
m1("a")
```
Expand Down Expand Up @@ -48,7 +48,7 @@ m1("a")

#### Q6. After defining a function in the interpreter, Scala returns the following. What does the

```
```scala
myfnc: ()Unit
```

Expand Down Expand Up @@ -76,7 +76,7 @@ myfnc: ()Unit

#### Q9. What type of object does this code create?

```
```scala
val x = (1234, "Active")
```

Expand Down Expand Up @@ -112,7 +112,7 @@ val x = (1234, "Active")

#### Q13. What is the value of z after executing this code?

```
```scala
val y = List('a','b')
val z = y::List('c')
```
Expand All @@ -136,3 +136,53 @@ val z = y::List('c')
##### answers missing


#### Q16. What is the data type of y after this code is executed?

```scala
val y = (math floor 3.1415 * 2)
```
- [ ] short
- [ ] double
- [ ] int
- [ ] bigInt


#### Q17. When using pattern matching, which character matches on any object?
- [ ] %
- [ ] _
- [ ] ^
- [ ] *


#### Q18. You have created an array using val. Can you change the value of any element of the array—and why or why not?

- [ ] 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.
- [ ] The 0th element is immutable and cannot be modified. All other elements can be modified.
- [ ] Yes, val does not make arrays immutable.
- [ ] No, val makes the array and values of the array immutable.


#### Q19. What is the output of this function?

```scala
def main () {
var a = 0
for (a<-1 until 5){println(a)}
```
- [ ] 1,2,3,4,5
- [ ] 0,1,2,3,4
- [ ] 1,2,3,4
- [ ] 2,3,4,5


#### Q20. What do you call objects with immutable state?

- [ ] singletons
- [ ] stationary objects
- [ ] functional objects
- [ ] fixed objects





0 comments on commit 20ba22f

Please sign in to comment.