Groovy Quiz 12 | Strings | Part 1 Reference video | Groovy Playground 1 Point for every correct answer | Let’s Get Started 1. Guess the output def name = "Raghav" println name println "My name is "+name Raghav My name is Raghav Raghav My name is name Exception 2. Guess the output def name = "Raghav" println "My name is "+name println "My name is ".concat(name) My name is Raghav My name is name My name is Raghav My name is Raghav Exception 3. Guess the output def name = "Raghav" println "My name is ${name}" My name is Raghav My name is ${name} Exception 4. Guess the output def name = "Raghav" println 'My name is ${name}' My name is Raghav My name is ${name} Exception 5. Guess the output def str = """This is a groovy class and we are learning Strings""" print str hint : Using triple single quotes or triple double quotes the String will be printed as it is (including next line) This is a groovy class and we are learning Strings This is a groovy class and we are learning Strings 6. Guess the output def str = "Groovy" print str.length() 5 6 Exception 7. Guess the output def str = "RAGHAV" print str[2] hint : index position starts from 0 A G H 8. Guess the output def str = "RAGHAV" print str[-3] hint: negative index position starts from backward and counts from 1 (not zero) A H G 9. Guess the output def str = "RAGHAV" print str.indexOf('V') 4 5 6 10. Guess the output def str = "RAGHAV" print str[0..2] hint: you can watch the groovy loops video – https://youtu.be/WsRJC9he7t0 RAG RA AGH Exception 11. Guess the output def str = "RAGHAV" print str[5..3] hint: start index position from backward VAH HAV Exception 12. Guess the output def str = "RAGHAV" print str[0,2,4] RGH RGA RAG Loading … 12 Share this:TwitterFacebookLinkedIn Related