Deck 2: Interacting With Ruby

Full screen (f)
exit full mode
Question
Unlike the print method the puts method displays text strings on separate lines.
Use Space or
up arrow
down arrow
to flip the card.
Question
A method is a collection of statements that is predefined within a class that can be used to interact with and control the operation of objects created based on the class.
Question
You can access a special Internet based version of the IRB by visiting http://tryruby.org/.
Question
Arithmetic expressions are evaluated based on a predetermined order referred to as the order of examination .
Question
A floating point value is a number that does not include a decimal point.
Question
Using the IRB you can gain insight as to the way Ruby keyboards, operators, and commands work.
Question
An expression is a series of keywords, operators and variables that when processed returns a result.
Question
The IRB is started from the operating system command prompt by entering start irb and pressing Enter.
Question
A class is a definition or template used as the basis for defining a new object and does not do anything by itself.
Question
Ruby programmers often use the IRB to test the execution of numeric expression like a calculator.
Question
By default, any time two integer numbers are divided in Ruby, the value that is returned is always an integer.
Question
The term instantiation describes a process whereby a new object is created.
Question
In addition to RDoc, you can view Ruby documentation using either the ri or the vd command line commands on your computer.
Question
The print method displays a line of text on the screen.
Question
You can easily access the documentation for most Ruby class methods via a system referred to as RDoc.
Question
You can access RDoc online at http://www.ruby-doc.org/.
Question
The term IRB stands for Interactive Ruby.
Question
Unlike other programming languages, Ruby does not require programmers to follow any language specific rules.
Question
In order to instantiate a new object you must use the new keyword.
Question
Nil is a value that representing a value of 0.
Question
Which of the following commands display a line of text on the screen?

A) puts
B) display
C) print
D) both a and c
Question
What value will the following expression evaluate to ____. irb(main):010:0> 7 * 4 / 3 - 4 % 3 + 8

A) 16
B) 14
C) 4
D) 20
Question
Which of the following statements is not true?

A) An object is created based on a predefined class template
B) An object inherits all of the features of the class upon which it is based
C) An object is a template that is used to define a class
D) None of the above
Question
The IRB does not provide access to classes, objects or variables more than 5 minutes old.
Question
Which of the following statements is not true?

A) All IRB sessions share a common memory space.
B) Classes, methods and variables that are defined in one IRB are not accessible in another session.
C) New IRB sessions can be started by opening a new console window and typing IRB.
D) New IRB sessions cane be started from within an existing irb accessing by typing IRB.
Question
An IRB session can by terminated by all of the following command except ____.

A) exit
B) irb_quit
C) irb -v
D) irb_exit
Question
In addition to the standard set of mathematical operator methods, Ruby also provides you with access to a collection of mathematical methods stored in which module?

A) Trig
B) Calculus
C) Math
D) Arithmetic
Question
You can instruct the IRB to load and execute a script named test.rb in c:\Ruby_Scripts\ using which of the following commands?

A) load 'c:\Ruby_Scripts\test.rb'
B) copy 'c:\Ruby_Scripts\test.rb'
C) run 'c:\Ruby_Scripts\test.rb'
D) execute 'c:\Ruby_Scripts\test.rb'
Question
A misspelled command is an example of what type or error?

A) Logical
B) Syntax
C) Runtime
D) None of the above
Question
Parentheses or quotation marks can be used to override the order of precedence.
Question
If you require a greater level of precision when working with numeric data, you must specify floating-point numbers (e.g. numbers with a decimal)
Question
The * operator is used to perform ____.

A) Addition
B) Multiplication
C) Division
D) Exponentiation
Question
The % operator is used to perform ____.

A) Addition
B) Multiplication
C) Division
D) Modulus
Question
The IRB ____.

A) Provides Ruby programmers with command line access to the Ruby parser.
B) Can be used to test the effects of Ruby statements.
C) Can be used to load and execute entire scripts.
D) All of the above.
Question
The math module includes many different types of methods that support advanced mathematical operations. Examples of the methods provided by this module include ____.

A) sqrt
B) acos
C) cos
D) All of the above
Question
The command irb -v ____.

A) Starts the IRB and displays its version number
B) Starts the IRB in a special graphic interface mode
C) Closes the IRB
D) None of the above
Question
When working with module methods, you can refer to methods using upper or lower case spelling, just as long as you properly spell the method's name.
Question
If you enter an incomplete Ruby statement into the IRB, it will ____.

A) Execute the incomplete statements and generate an error
B) Display a modified command prompt and wait on you to finish entering the statement
C) Display a warning message and reject your input
D) None of the above
Question
Failure to follow Ruby's syntax rules when formulating script statements can result in an error that prevents your script from executing.
Question
When working with the IRB, you can ____.

A) Pass the IRB a number of statements
B) Pass the name of a Ruby script you want to execute
C) Pass the name of a Ruby script along with arguments for that script
D) All of the above.
Question
Ruby supports thousands of methods. You can use the ____ system to access documentation on these methods.

A) ri
B) RDoc
C) DocView
D) a and b
Question
You can retrieve player input using which of the STDIN class's methods?

A) puts
B) gets
C) retrieve
D) catch
Question
A method ____.

A) Is a collection of statements defined within a class
B) Can be used to interact with objects
C) Can be used to control the operation of an object
D) All of the above
Question
What value will the following expression evaluate to? irb(main):010:0> (4 + 7) * 3 - 7 / (2 + 5) ** 2

A) 45
B) 25
C) 33
D) 47
Question
In Ruby variable substitution is performed within a string by placing a variable name within what set of characters?

A) %Q{ and }
B) #{ and }
C) %{ and }
D) { and }
Question
According to Ruby's order of precedence, arithmetic expressions are resolved in which of the following orders?

A) Exponentiation > multiplication, division, modulus > addition, subtraction
B) Modulus > exponentiation > division, modulus > addition, subtraction
C) Addition, subtraction, division, multiplication > modulus, exponentiation
D) None of the above
Question
Which of the following is a valid way of creating a string within a Ruby statement?

A) Embed text within an opening %Q{ and } characters.
B) Embed text within a pair of double quotation marks.
C) Embed text within a pair of single quotation marks.
D) Both a and b.
Question
The round method is associated with many different classes, including all of the following except ____.

A) Numeric
B) Integer
C) Float
D) String
Question
Within your Ruby scripts, an escape character is a pair of characters that begin with the ____ character followed by a letter.

A) #
B) _
C) !
D) \
Question
Which of the following command line commands will allow you to view information about the Numeric class's round method?

A) ri.numeric.round
B) ri numeric(round)
C) vd numeric.round
D) ri Numeric.round
Question
The following statement shows and incomplete statement entered into the IRB. irb(main):003:0> 5 - 1 + What of the following examples shows the modified command prompt that the IRB will display next?

A) irb(main):004:7:*
B) irb(input):004:0:>
C) irb(main):004:0*
D) irb(multi):004:0:
Question
What value will the following expression evaluate to? irb(main):010:0> 4 + 7 * 3 - 7 / 2 + 5 ** 2

A) 45
B) 25
C) 35
D) 47
Question
What does Ruby do when it has operators with the same level or precedence to evaluate?

A) It processes them from left to right
B) It processes them from right to left
C) It processes all multiplication before division and all addition before subtraction
D) It processes all division before multiplication and all subtraction before addition
Question
Which of the following statements is not true regarding indentation within your Ruby scripts?

A) Indenting statements helps to visually organize them
B) Indenting statements can make them easier to read and understand
C) Indentation is required for your script to execute properly
D) Indentation is consider a good programming practice
Question
A string containing the \a escape character instructs Ruby to ____ when the statement that contains it executes.

A) Beep
B) Pause
C) Terminate
D) Insert a blank line
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/55
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 2: Interacting With Ruby
1
Unlike the print method the puts method displays text strings on separate lines.
True
2
A method is a collection of statements that is predefined within a class that can be used to interact with and control the operation of objects created based on the class.
True
3
You can access a special Internet based version of the IRB by visiting http://tryruby.org/.
True
4
Arithmetic expressions are evaluated based on a predetermined order referred to as the order of examination .
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
5
A floating point value is a number that does not include a decimal point.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
6
Using the IRB you can gain insight as to the way Ruby keyboards, operators, and commands work.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
7
An expression is a series of keywords, operators and variables that when processed returns a result.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
8
The IRB is started from the operating system command prompt by entering start irb and pressing Enter.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
9
A class is a definition or template used as the basis for defining a new object and does not do anything by itself.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
10
Ruby programmers often use the IRB to test the execution of numeric expression like a calculator.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
11
By default, any time two integer numbers are divided in Ruby, the value that is returned is always an integer.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
12
The term instantiation describes a process whereby a new object is created.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
13
In addition to RDoc, you can view Ruby documentation using either the ri or the vd command line commands on your computer.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
14
The print method displays a line of text on the screen.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
15
You can easily access the documentation for most Ruby class methods via a system referred to as RDoc.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
16
You can access RDoc online at http://www.ruby-doc.org/.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
17
The term IRB stands for Interactive Ruby.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
18
Unlike other programming languages, Ruby does not require programmers to follow any language specific rules.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
19
In order to instantiate a new object you must use the new keyword.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
20
Nil is a value that representing a value of 0.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
21
Which of the following commands display a line of text on the screen?

A) puts
B) display
C) print
D) both a and c
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
22
What value will the following expression evaluate to ____. irb(main):010:0> 7 * 4 / 3 - 4 % 3 + 8

A) 16
B) 14
C) 4
D) 20
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
23
Which of the following statements is not true?

A) An object is created based on a predefined class template
B) An object inherits all of the features of the class upon which it is based
C) An object is a template that is used to define a class
D) None of the above
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
24
The IRB does not provide access to classes, objects or variables more than 5 minutes old.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
25
Which of the following statements is not true?

A) All IRB sessions share a common memory space.
B) Classes, methods and variables that are defined in one IRB are not accessible in another session.
C) New IRB sessions can be started by opening a new console window and typing IRB.
D) New IRB sessions cane be started from within an existing irb accessing by typing IRB.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
26
An IRB session can by terminated by all of the following command except ____.

A) exit
B) irb_quit
C) irb -v
D) irb_exit
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
27
In addition to the standard set of mathematical operator methods, Ruby also provides you with access to a collection of mathematical methods stored in which module?

A) Trig
B) Calculus
C) Math
D) Arithmetic
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
28
You can instruct the IRB to load and execute a script named test.rb in c:\Ruby_Scripts\ using which of the following commands?

A) load 'c:\Ruby_Scripts\test.rb'
B) copy 'c:\Ruby_Scripts\test.rb'
C) run 'c:\Ruby_Scripts\test.rb'
D) execute 'c:\Ruby_Scripts\test.rb'
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
29
A misspelled command is an example of what type or error?

A) Logical
B) Syntax
C) Runtime
D) None of the above
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
30
Parentheses or quotation marks can be used to override the order of precedence.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
31
If you require a greater level of precision when working with numeric data, you must specify floating-point numbers (e.g. numbers with a decimal)
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
32
The * operator is used to perform ____.

A) Addition
B) Multiplication
C) Division
D) Exponentiation
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
33
The % operator is used to perform ____.

A) Addition
B) Multiplication
C) Division
D) Modulus
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
34
The IRB ____.

A) Provides Ruby programmers with command line access to the Ruby parser.
B) Can be used to test the effects of Ruby statements.
C) Can be used to load and execute entire scripts.
D) All of the above.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
35
The math module includes many different types of methods that support advanced mathematical operations. Examples of the methods provided by this module include ____.

A) sqrt
B) acos
C) cos
D) All of the above
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
36
The command irb -v ____.

A) Starts the IRB and displays its version number
B) Starts the IRB in a special graphic interface mode
C) Closes the IRB
D) None of the above
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
37
When working with module methods, you can refer to methods using upper or lower case spelling, just as long as you properly spell the method's name.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
38
If you enter an incomplete Ruby statement into the IRB, it will ____.

A) Execute the incomplete statements and generate an error
B) Display a modified command prompt and wait on you to finish entering the statement
C) Display a warning message and reject your input
D) None of the above
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
39
Failure to follow Ruby's syntax rules when formulating script statements can result in an error that prevents your script from executing.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
40
When working with the IRB, you can ____.

A) Pass the IRB a number of statements
B) Pass the name of a Ruby script you want to execute
C) Pass the name of a Ruby script along with arguments for that script
D) All of the above.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
41
Ruby supports thousands of methods. You can use the ____ system to access documentation on these methods.

A) ri
B) RDoc
C) DocView
D) a and b
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
42
You can retrieve player input using which of the STDIN class's methods?

A) puts
B) gets
C) retrieve
D) catch
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
43
A method ____.

A) Is a collection of statements defined within a class
B) Can be used to interact with objects
C) Can be used to control the operation of an object
D) All of the above
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
44
What value will the following expression evaluate to? irb(main):010:0> (4 + 7) * 3 - 7 / (2 + 5) ** 2

A) 45
B) 25
C) 33
D) 47
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
45
In Ruby variable substitution is performed within a string by placing a variable name within what set of characters?

A) %Q{ and }
B) #{ and }
C) %{ and }
D) { and }
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
46
According to Ruby's order of precedence, arithmetic expressions are resolved in which of the following orders?

A) Exponentiation > multiplication, division, modulus > addition, subtraction
B) Modulus > exponentiation > division, modulus > addition, subtraction
C) Addition, subtraction, division, multiplication > modulus, exponentiation
D) None of the above
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
47
Which of the following is a valid way of creating a string within a Ruby statement?

A) Embed text within an opening %Q{ and } characters.
B) Embed text within a pair of double quotation marks.
C) Embed text within a pair of single quotation marks.
D) Both a and b.
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
48
The round method is associated with many different classes, including all of the following except ____.

A) Numeric
B) Integer
C) Float
D) String
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
49
Within your Ruby scripts, an escape character is a pair of characters that begin with the ____ character followed by a letter.

A) #
B) _
C) !
D) \
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
50
Which of the following command line commands will allow you to view information about the Numeric class's round method?

A) ri.numeric.round
B) ri numeric(round)
C) vd numeric.round
D) ri Numeric.round
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
51
The following statement shows and incomplete statement entered into the IRB. irb(main):003:0> 5 - 1 + What of the following examples shows the modified command prompt that the IRB will display next?

A) irb(main):004:7:*
B) irb(input):004:0:>
C) irb(main):004:0*
D) irb(multi):004:0:
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
52
What value will the following expression evaluate to? irb(main):010:0> 4 + 7 * 3 - 7 / 2 + 5 ** 2

A) 45
B) 25
C) 35
D) 47
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
53
What does Ruby do when it has operators with the same level or precedence to evaluate?

A) It processes them from left to right
B) It processes them from right to left
C) It processes all multiplication before division and all addition before subtraction
D) It processes all division before multiplication and all subtraction before addition
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
54
Which of the following statements is not true regarding indentation within your Ruby scripts?

A) Indenting statements helps to visually organize them
B) Indenting statements can make them easier to read and understand
C) Indentation is required for your script to execute properly
D) Indentation is consider a good programming practice
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
55
A string containing the \a escape character instructs Ruby to ____ when the statement that contains it executes.

A) Beep
B) Pause
C) Terminate
D) Insert a blank line
Unlock Deck
Unlock for access to all 55 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 55 flashcards in this deck.