Groovy Quiz 6 | Relational & Logical Operators


Reference video | Groovy Playground


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

1.

Relational Operators – Check if the symbols and description matches

==  – equal
!= – different
< – less than
<= – less than or equal
> – greater than
>= – greater than or equal
=== – identical (Since Groovy 3.0.0)
!== – not identical (Since Groovy 3.0.0)

 
 

2.

Guess the output
(Can run and check code here – https://groovy-playground.appspot.com/)

//Relational Operators
println (1 + 2 == 3)
println (3 != 4)

println (-2 < 3)
println (2 <= 2)
println (3 <= 4)

println (5 > 1)
println (5 >= -2)
 
 

3.

Logical Operators – Check if the symbol and description matches

&&: logical “and”
||: logical “or”
!: logical “not”

 
 

4.

Logical Operators – Guess the output

println !false           
println true && true     
println true || false
 
 
 

5.

Guess the output

println ((!false && false) == false)

hint: The logical “not” has a higher priority than the logical “and”.

 
 

6.

Guess the output

print (true || true && false)

hint: The logical “and” has a higher priority than the logical “or”.

 
 

7.

What is Short-circuiting

 
 
 

13