Operator Precedence Rules in Ruby

Descrição

Think you know operator precedence rules? Test yourself on operator precedence rules in ruby with this short quiz.
Domhnall Murphy
Quiz por Domhnall Murphy, atualizado more than 1 year ago
Domhnall Murphy
Criado por Domhnall Murphy aproximadamente 2 anos atrás
2422
0

Resumo de Recurso

Questão 1

Questão
What is the output from the following ruby statement: puts (1 + 2 * 2)
Responda
  • 5
  • 6
  • 3
  • 4

Questão 2

Questão
What is the output from the following ruby statement: puts (4 * 6 / 2 * 2)
Responda
  • 6
  • 24
  • 3
  • 0

Questão 3

Questão
What is the output from the following ruby expression: puts (4 / 2 * 2 + 2 / 2)
Responda
  • 4
  • 2
  • 3
  • 5

Questão 4

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

Questão 5

Questão
What is the output from the following ruby statement: puts (4 * 2 ** 2 * 2)
Responda
  • 32
  • 16
  • 128
  • 64

Questão 6

Questão
What is the output from the final ruby statement: c = 3 d = 4 puts (c or d == 7)
Responda
  • 3
  • true
  • false
  • 1

Questão 7

Questão
What is the output of the last ruby statement x = 5 && 4 puts x
Responda
  • true
  • false
  • 5
  • 4

Questão 8

Questão
What is the output of the last ruby statement x = 5 and 4 puts x
Responda
  • true
  • false
  • 5
  • 4

Questão 9

Questão
What is the output from the final ruby statement: a = false b = true ! a || b = false puts b
Responda
  • true
  • false
  • 0
  • 1

Questão 10

Questão
What is the output from the following ruby statement puts (13 & 10 << 1)
Responda
  • 4
  • 16
  • 5
  • 8

Questão 11

Questão
What is the output from the final ruby statement a = false b = true puts (a && b ? 'foo' : 'bar')
Responda
  • true
  • false
  • foo
  • bar

Questão 12

Questão
What is the output from the final ruby statement a = false b = true puts (a and b ? 'foo' : 'bar')
Responda
  • true
  • false
  • foo
  • bar

Semelhante

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