CSE 3901 MIDTERM 1 MOCK EXAM AND
STUDY MATERIAL WITH CODING AND SYSTEM
DESIGN QUESTIONS
◉ Start of method
In the block
In the block
End of method.
Answer: What does the following code output?
def call_block
puts 'Start of method'
yield
yield
puts 'End of method'
end
call_block {puts 'In the block'}
◉ equal? : Checks if the object id is the same (reference value)
eql? : True if the receiver and argument have both the same type and
equal values (same hash key).
,=== : tests range inclusion
== : Checks if the value of two operands are equal or not.
Answer: What's the difference between equal?, eql?, ===, and == ?
◉ 10^20.
Answer: a = 10
b = 20
What is the return value for a**b?
◉ position = "cat o' 9 tails" =~ /a/
puts position.
Answer: write a statement that prints the index of the first
occurrence of 'a' in the string "cat o' 9 tails"
◉ FixNum, Float, Rational, Complex.
Answer: what are the different number types in ruby?
◉ #=> expected.
Answer: what is the ruby convention to indicate an expected result
as a comment on a line of code?
, ◉ modulus, not remainder.
Answer: what is % in ruby?
◉ && || ! and or not - Words have lower precedence.
Answer: what are the logical operators in ruby and what is the
precedence?
◉ self, nil.
Answer: in ruby what is the object name for 'this' and 'null'
◉ true, false
nil also evaluates to false
0 is not false, it is true just like 1 or -4!.
Answer: ruby: what are the boolean values?
◉ __FILE__.
Answer: ruby: what is the current source file name?
◉ __LINE__.
Answer: ruby: what is the current line number name?
STUDY MATERIAL WITH CODING AND SYSTEM
DESIGN QUESTIONS
◉ Start of method
In the block
In the block
End of method.
Answer: What does the following code output?
def call_block
puts 'Start of method'
yield
yield
puts 'End of method'
end
call_block {puts 'In the block'}
◉ equal? : Checks if the object id is the same (reference value)
eql? : True if the receiver and argument have both the same type and
equal values (same hash key).
,=== : tests range inclusion
== : Checks if the value of two operands are equal or not.
Answer: What's the difference between equal?, eql?, ===, and == ?
◉ 10^20.
Answer: a = 10
b = 20
What is the return value for a**b?
◉ position = "cat o' 9 tails" =~ /a/
puts position.
Answer: write a statement that prints the index of the first
occurrence of 'a' in the string "cat o' 9 tails"
◉ FixNum, Float, Rational, Complex.
Answer: what are the different number types in ruby?
◉ #=> expected.
Answer: what is the ruby convention to indicate an expected result
as a comment on a line of code?
, ◉ modulus, not remainder.
Answer: what is % in ruby?
◉ && || ! and or not - Words have lower precedence.
Answer: what are the logical operators in ruby and what is the
precedence?
◉ self, nil.
Answer: in ruby what is the object name for 'this' and 'null'
◉ true, false
nil also evaluates to false
0 is not false, it is true just like 1 or -4!.
Answer: ruby: what are the boolean values?
◉ __FILE__.
Answer: ruby: what is the current source file name?
◉ __LINE__.
Answer: ruby: what is the current line number name?