Groovy Quiz 21 | Ranges Reference video | Groovy Playground 1 Point for every correct answer | Let’s Get Started 1. Is this statement True Range is used to create a list of sequential values e.g 1..10 Yes No 2. Is the following statement true There are 2 types of ranges 1. Inclusive e.g. 1..10 (will go from 1 to 10) 2. Exclusive e.g. 1..<10 (will go from 1 to 9) Yes No 3. Guess the output (Can run and check code here – https://groovy-playground.appspot.com/) def myRange = 1..10 print myRange 1 2 3 4 5 6 7 8 9 10 1..10 null 4. def myRange = 1..10 println myRange.size() println myRange.getFrom() println myRange.getTo() 10 1 10 10 1 9 5. def myRange = 1..10 println myRange.from ==1 println myRange.to == 10 true false false true true true false false 6. def myRange = 1..10 println myRange.get(3) println myRange[3] 3 4 3 3 4 3 4 4 7. def myRange = 1..10 println myRange.contains(5) println myRange.isReverse() true false true true false true 8. def range1 = 10..1 def range2 = range1.subList(1,5) println range2 1..5 2..6 5..2 9. for(int num in 1..10){ println num } 1 2 3 4 5 6 7 8 9 10 null 10. def range1 = 1..10 range1.each{ i -> println "$i" } 1 2 3 4 5 6 7 8 9 10 null Loading … 7 Share this:TwitterFacebookLinkedIn Related