Groovy Quiz 18 | Lists | Part-2 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/) def myList = [1,2,3,4,5] myList.add(10) myList<<20 print myList [1, 2, 3, 4, 5] [1, 2, 3, 4, 5, 10, 20] exception [1, 2, 3, 4, 5, 10] 2. def myList = [1,2,3,4,5] myList.add(3,33) print myList [1, 2, 33, 3, 4, 5] [1, 2, 3, 33, 4, 5] 3. def myList = [1,2,3,4,5] myList.remove(3) print myList [1, 2, 4, 5] [1, 2, 3, 5] exception 4. def myList = [1,2,3,4,5] myList + [10,20] print myList [1, 2, 3, 4, 5,10,20] [1, 2, 3, 4, 5] 5. def myList = [1,2,3,4,5] myList = myList + [10,20] print myList [1, 2, 3, 4, 5, 10, 20] [1, 2, 3, 4, 5] 6. def myList = [1,2,3,4,5] myList = myList.plus([50]) print myList exception [1, 2, 3, 4, 5, 50] [1, 2, 3, 4, 5] 7. def myList = [1,2,3,4,5] myList = myList - [3,4] myList = myList.minus([5]) print myList [1, 2, 3, 4] [1, 2] [1, 2, 3, 4, 5] exception 8. def myList = [1,2,3,4,5] myList.pop() print myList [1, 2, 3, 4] [2,3,4,5] [1,2,3,4,5] 9. //Find match in a list def myList = [1,2,3,4,5] print myList.intersect([2,4,10,20]) [2, 4] null exception 10. def myList = [1,2,3,4,5] myList = myList.reverse() print myList [1,2,3,4,5] [5, 4, 3, 2, 1] exception Loading … 5