CSE 3901 Final Exam WITH CORRECT |\ |\ |\ |\ |\ |\
ANSWERS
in ruby, objects... - CORRECT ANSWERS ✔✔have types, but
|\ |\ |\ |\ |\ |\ |\ |\ |\
variables don't |\
ruby is an interpreted program, list advantages and
|\ |\ |\ |\ |\ |\ |\ |\
disadvantages - CORRECT ANSWERS ✔✔Advantages |\ |\ |\ |\
- platform independence
|\ |\
- read-eval-print loop
|\ |\
- reflection
|\
Disads
- speed
|\
- later error detection at run time
|\ |\ |\ |\ |\ |\
List examples of number literals in Ruby - CORRECT ANSWERS
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\
✔✔83, 0123, 0x53, 0b1010011, 0b101_0011, 123.45, 1.2345e2,
|\ |\ |\ |\ |\ |\ |\
2/3r
string literals in ruby - CORRECT ANSWERS ✔✔" " and ' ' are
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\
delimeters, interpolation of #{ } occurs inside " " |\ |\ |\ |\ |\ |\ |\ |\
%Q" ... " custom delimeters or q
|\ |\ |\ |\ |\ |\
ranges in ruby... - CORRECT ANSWERS ✔✔0..4 is end inclusive (0,
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\
1, 2, 3, 4)
|\ |\ |\ |\
,0...4 is end exclusive (0, 1, 2, 3)
|\ |\ |\ |\ |\ |\ |\
single line comment in Ruby, multi line looks... - CORRECT
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\
ANSWERS ✔✔#This is a comment |\ |\ |\ |\
=begin
...comment
=end
what does ** do? what about %? - CORRECT ANSWERS ✔✔power
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\
so 2**2 is 2 squared
|\ |\ |\ |\
% is modulus not remainder
|\ |\ |\ |\
difference between 1/3r / 1/2r and (1/3r) / (1/2r)... - CORRECT
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\
ANSWERS ✔✔first one is 1/6r since it is basically (1/3r)/2r and the
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\
second one is 2/3r actual division
|\ |\ |\ |\ |\ |\
what is <=>? - CORRECT ANSWERS ✔✔spaceship
|\ |\ |\ |\ |\ |\ |\
operator...returns -1/0/1 if LHS is smaller/equal/larger than RHS |\ |\ |\ |\ |\ |\ |\
what is self and nil? - CORRECT ANSWERS ✔✔self is the receiver
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\
of the current method and nil is nothingness
|\ |\ |\ |\ |\ |\ |\
nil evaluates to... - CORRECT ANSWERS ✔✔false
|\ |\ |\ |\ |\ |\
, local variables start with - CORRECT ANSWERS ✔✔lowercase or _
|\ |\ |\ |\ |\ |\ |\ |\ |\
global variables start with... - CORRECT ANSWERS ✔✔$
|\ |\ |\ |\ |\ |\ |\
instances start with... - CORRECT ANSWERS ✔✔@ |\ |\ |\ |\ |\ |\
class variables start with... - CORRECT ANSWERS ✔✔@@
|\ |\ |\ |\ |\ |\ |\
conditional syntax in ruby... - CORRECT ANSWERS ✔✔if-elsif-else- |\ |\ |\ |\ |\ |\ |\
end
basic iteration syntax - CORRECT ANSWERS ✔✔while (condition)
|\ |\ |\ |\ |\ |\ |\ |\
do...
until (condition) do... |\ |\
begin i = i+1 end while i < max |\ |\ |\ |\ |\ |\ |\ |\
keyword def for definition |\ |\ |\
- no types for parameters
|\ |\ |\ |\
- no return type
|\ |\ |\
all functions return something
|\ |\ |\
def foo(x, y) |\ |\
|\ x + y (last statement is returned)
|\ |\ |\ |\ |\ |\
end - CORRECT ANSWERS ✔✔
|\ |\ |\ |\
ANSWERS
in ruby, objects... - CORRECT ANSWERS ✔✔have types, but
|\ |\ |\ |\ |\ |\ |\ |\ |\
variables don't |\
ruby is an interpreted program, list advantages and
|\ |\ |\ |\ |\ |\ |\ |\
disadvantages - CORRECT ANSWERS ✔✔Advantages |\ |\ |\ |\
- platform independence
|\ |\
- read-eval-print loop
|\ |\
- reflection
|\
Disads
- speed
|\
- later error detection at run time
|\ |\ |\ |\ |\ |\
List examples of number literals in Ruby - CORRECT ANSWERS
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\
✔✔83, 0123, 0x53, 0b1010011, 0b101_0011, 123.45, 1.2345e2,
|\ |\ |\ |\ |\ |\ |\
2/3r
string literals in ruby - CORRECT ANSWERS ✔✔" " and ' ' are
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\
delimeters, interpolation of #{ } occurs inside " " |\ |\ |\ |\ |\ |\ |\ |\
%Q" ... " custom delimeters or q
|\ |\ |\ |\ |\ |\
ranges in ruby... - CORRECT ANSWERS ✔✔0..4 is end inclusive (0,
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\
1, 2, 3, 4)
|\ |\ |\ |\
,0...4 is end exclusive (0, 1, 2, 3)
|\ |\ |\ |\ |\ |\ |\
single line comment in Ruby, multi line looks... - CORRECT
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\
ANSWERS ✔✔#This is a comment |\ |\ |\ |\
=begin
...comment
=end
what does ** do? what about %? - CORRECT ANSWERS ✔✔power
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\
so 2**2 is 2 squared
|\ |\ |\ |\
% is modulus not remainder
|\ |\ |\ |\
difference between 1/3r / 1/2r and (1/3r) / (1/2r)... - CORRECT
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\
ANSWERS ✔✔first one is 1/6r since it is basically (1/3r)/2r and the
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\
second one is 2/3r actual division
|\ |\ |\ |\ |\ |\
what is <=>? - CORRECT ANSWERS ✔✔spaceship
|\ |\ |\ |\ |\ |\ |\
operator...returns -1/0/1 if LHS is smaller/equal/larger than RHS |\ |\ |\ |\ |\ |\ |\
what is self and nil? - CORRECT ANSWERS ✔✔self is the receiver
|\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\ |\
of the current method and nil is nothingness
|\ |\ |\ |\ |\ |\ |\
nil evaluates to... - CORRECT ANSWERS ✔✔false
|\ |\ |\ |\ |\ |\
, local variables start with - CORRECT ANSWERS ✔✔lowercase or _
|\ |\ |\ |\ |\ |\ |\ |\ |\
global variables start with... - CORRECT ANSWERS ✔✔$
|\ |\ |\ |\ |\ |\ |\
instances start with... - CORRECT ANSWERS ✔✔@ |\ |\ |\ |\ |\ |\
class variables start with... - CORRECT ANSWERS ✔✔@@
|\ |\ |\ |\ |\ |\ |\
conditional syntax in ruby... - CORRECT ANSWERS ✔✔if-elsif-else- |\ |\ |\ |\ |\ |\ |\
end
basic iteration syntax - CORRECT ANSWERS ✔✔while (condition)
|\ |\ |\ |\ |\ |\ |\ |\
do...
until (condition) do... |\ |\
begin i = i+1 end while i < max |\ |\ |\ |\ |\ |\ |\ |\
keyword def for definition |\ |\ |\
- no types for parameters
|\ |\ |\ |\
- no return type
|\ |\ |\
all functions return something
|\ |\ |\
def foo(x, y) |\ |\
|\ x + y (last statement is returned)
|\ |\ |\ |\ |\ |\
end - CORRECT ANSWERS ✔✔
|\ |\ |\ |\