Groovy Quiz 10 | While Loop


Reference video | Groovy Playground


1 Point for every correct answer | Let’s Get Started

1.

Guess the output

(Can run and check code here – https://groovy-playground.appspot.com/)

int i = 1
while (i<5){
    println i
    i = i+1
}
 
 
 

2.

Guess the output

def x = 0
def y = 5
while ( y-- > 0 ) {
    x++
}
println x
 
 
 

11