Operator Precedence Rules in Ruby

Descripción

Think you know operator precedence rules? Test yourself on operator precedence rules in ruby with this short quiz.
Domhnall Murphy
Test por Domhnall Murphy, actualizado hace más de 1 año
Domhnall Murphy
Creado por Domhnall Murphy hace alrededor de 2 años
2422
0

Resumen del Recurso

Pregunta 1

Pregunta
What is the output from the following ruby statement: puts (1 + 2 * 2)
Respuesta
  • 5
  • 6
  • 3
  • 4

Pregunta 2

Pregunta
What is the output from the following ruby statement: puts (4 * 6 / 2 * 2)
Respuesta
  • 6
  • 24
  • 3
  • 0

Pregunta 3

Pregunta
What is the output from the following ruby expression: puts (4 / 2 * 2 + 2 / 2)
Respuesta
  • 4
  • 2
  • 3
  • 5

Pregunta 4

Pregunta
What is the output from the following ruby statement: puts (5 + 10 % 3 + 6 / 2)
Respuesta
  • 9
  • 3
  • \(5 \frac{1}{2} \)
  • \(6 \frac{1}{2} \)

Pregunta 5

Pregunta
What is the output from the following ruby statement: puts (4 * 2 ** 2 * 2)
Respuesta
  • 32
  • 16
  • 128
  • 64

Pregunta 6

Pregunta
What is the output from the final ruby statement: c = 3 d = 4 puts (c or d == 7)
Respuesta
  • 3
  • true
  • false
  • 1

Pregunta 7

Pregunta
What is the output of the last ruby statement x = 5 && 4 puts x
Respuesta
  • true
  • false
  • 5
  • 4

Pregunta 8

Pregunta
What is the output of the last ruby statement x = 5 and 4 puts x
Respuesta
  • true
  • false
  • 5
  • 4

Pregunta 9

Pregunta
What is the output from the final ruby statement: a = false b = true ! a || b = false puts b
Respuesta
  • true
  • false
  • 0
  • 1

Pregunta 10

Pregunta
What is the output from the following ruby statement puts (13 & 10 << 1)
Respuesta
  • 4
  • 16
  • 5
  • 8

Pregunta 11

Pregunta
What is the output from the final ruby statement a = false b = true puts (a && b ? 'foo' : 'bar')
Respuesta
  • true
  • false
  • foo
  • bar

Pregunta 12

Pregunta
What is the output from the final ruby statement a = false b = true puts (a and b ? 'foo' : 'bar')
Respuesta
  • true
  • false
  • foo
  • bar
Mostrar resumen completo Ocultar resumen completo

Similar

HTTPS explained with Carrier Pigeons
Shannon Anderson-Rush
Historical Development of Computer Languages
Shannon Anderson-Rush
Useful String Methods
Shannon Anderson-Rush
Flvs foundations of programming dba 2
mariaha vassar
Python Quiz
karljmurphy
computer systems and programming quiz
Molly Batch
Think Python
tsilvo2001
C Programming
Miki Rana
Generations of Programming Languages
Balikkoftesi
Mapa Conceptual - Arreglos
ciroivan94