Groovy Quiz 9 | For Loop Reference video | Groovy Playground 1 Point for every correct answer | Let’s Get Started 1. Traditional for loop – Guess the output (Can run and check code here – https://groovy-playground.appspot.com/) for(int num=1; num<5; num++){ println num } 1 2 3 4 5 1 2 3 4 Exception 2. for in loop – Guess the output for (num in 1..5){ println num } 1 2 3 4 5 1 2 3 4 2 3 4 exception 3. Guess the output 1.upto(5){ println "I love Groovy" } I love Groovy I love Groovy I love Groovy I love Groovy I love Groovy Exception 4. Guess the Output 1.upto(5){ println "$it" } 1 2 3 4 1 2 3 4 5 5. Guess the output 5.times{ println "I Love Programming" } I Love Programming I Love Programming I Love Programming I Love Programming I Love Programming Exception 6. Guess the output Run and check here – https://groovy-playground.appspot.com/ 5.times{ println "$it" } 1 2 3 4 5 0 1 2 3 4 7. Guess the output 1.step(10,2){ println "$it" } 1 3 5 7 9 0 2 4 6 8 10 exception 8. Guess the output x = 0 for ( i in [0, 1, 2, 3, 4] ) { x += i } println x 4 10 20 9. Guess the output def map = ["name":"Raghav", "subject":"Groovy"] for (entry in map){ println entry } Raghav Groovy name=Raghav subject=Groovy 10. Guess the output def map = ["name":"Raghav", "subject":"Groovy"] for (entry in map){ println entry.key } name subject Raghav Groovy name=Raghav subject=Groovy 11. Guess the output def map = ["name":"Raghav", "subject":"Groovy"] for (entry in map){ println entry.value } name=Raghav subject=Groovy Raghav Groovy Loading … 11