Groovy Quiz 22 | Input & Output


Reference video | Groovy Playground


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

1.

Following statement is used to get a String input from the console

System.console().readLine()

 

 
 

2.

Following statement is used to get an Integer input from the console

System.console().readLine().toInteger()

 

 
 

3.

Guess the output

def myName = "Raghav"
println "My name is $myName"
printf "My name is %s", myName
 
 
 

4.

printf "%s | %d | %.2f ", ["Raghav", 10, 20.22]

 
 
 

5.

padding

printf "%-10s | %10s", ["Raghav", "Groovy"]

 

 
 
 

9