Operator Precedence Rules in Ruby

Beschreibung

Think you know operator precedence rules? Test yourself on operator precedence rules in ruby with this short quiz.
Domhnall Murphy
Quiz von Domhnall Murphy, aktualisiert more than 1 year ago
Domhnall Murphy
Erstellt von Domhnall Murphy vor etwa 2 Jahre
2425
0

Zusammenfassung der Ressource

Frage 1

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

Frage 2

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

Frage 3

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

Frage 4

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

Frage 5

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

Frage 6

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

Frage 7

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

Frage 8

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

Frage 9

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

Frage 10

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

Frage 11

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

Frage 12

Frage
What is the output from the final ruby statement a = false b = true puts (a and b ? 'foo' : 'bar')
Antworten
  • true
  • false
  • foo
  • bar
Zusammenfassung anzeigen Zusammenfassung ausblenden

ähnlicher Inhalt

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