Groovy Quiz 13 | Strings | Part 2


Reference video | Groovy Playground


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

1.

Guess the output

def str = "RAGHAV"
print str.substring(3)
 
 
 

2.

Guess the output

def str = "RAGHAV"
print str.substring(1,3)
 
 
 

3.

def str = "RAGHAV"
print str.subSequence(1,3)
 
 
 

4.

Run code here – https://www.tutorialspoint.com/execute_groovy_online.php

def str = "Automation Step by Step"
print str.split(" ")
 
 
 

5.

You can run and check code here – https://groovy-playground.appspot.com/
Guess the output

def str = "Automation Step by Step"
print str-("Automation")
 
 
 

6.

def str = "Automation Step by Step"
print str-("Step")
 
 

7.

def str = "This is a groovy class"
print str.replace("class","session")
 
 
 

8.

def str = "Automation Step by Step"
print str.toLowerCase()
 
 
 

9.

def str = "Automation Step by Step"
print str.toUpperCase()
 
 
 

10.

def str = "Raghav"
print str.toList()
 
 
 

10