Home »
MCQs »
Scala MCQs
The correct output of the following code is | Scala Question 1
10. The correct output of the following code is,
object MyClass {
def main(args: Array[String]) {
var i,j=0
for(i <- 0 to 3){
for(j <- 0 until 2){
if(i + j == 3){
print((i*j)+"\t")
}
}
}
}
}
- 3 3
- 2 0
- 0 2
- 1 1
Answer: B) 2 0
Explanation:
In a nested loop, we will print values, The first iteration is 2, 1 and the second is 3, 0.