2026 COMPLETE QUESTIONS AND ANSWERS
◉ mutators. Answer: growing/shrinks
push and pop (add/remove from the end)
shift unshift (add/remove from the beginning)
modifies the receiver
◉ fifo queue (ruby). Answer: push + shift
◉ map. Answer: creates a new array based on a block, element by
element
a.map { |item| block }
◉ reduce. Answer: transforms an array into a single value by
incorporating one element at a time
a.reduce(init) { |acc, item| block}
value returned by block is the next acc
◉ splat operator *. Answer: splits/gather arrays/elements
not really an operator because it must be outermost
on RHS splat generalizes a split
,a, b, c = 1 * [2,3] #=> a,b,c = 1,2,3
on LHS spalt generalizes a gather
a, b, *r = 1,2,3,4 #=> r = [3,4]
◉ x.is_a? <class>. Answer: returns true if x's class is within a
hierarchy of the class argument
◉ x.instance_of? <class>. Answer: returns true only if x is an object
of that specific class
◉ x.object_id. Answer: returns memory address
◉ hashes. Answer: similar to maps
◉ partial map. Answer: keys -> values, uses array syntax. Passing a
parameter to a new hash give every new key that value as a default
◉ iteration for hashes. Answer: each{ |key,value|}, each_key,
each_value
Merge: combines 2 hases
Filter delete_if, keep_if
,◉ symbols. Answer: unique, immutable strings, prefixed like this
:symbol
◉ symbol.to_s or "string".intern. Answer: to convert between
symbol and string
◉ constructor (ruby). Answer: def initialize
◉ instance variables. Answer: appear inside a method and start with
@
◉ class variables. Answer: can appear anywhere, @@
◉ single inheritance. Answer: def subclass < superclass. Ruby
classes can only inherit from a single other class
◉ Modules. Answer: provide mixins and name space
◉ namespace. Answer: cannot be instantiated, but they can establish
a space throughout which all code that refers to some symbol
module Stockable
class Item...end
def self.inventory ... end
, end
accessing via scoping (::)
◉ IP Addresses. Answer: unique 32 bit number. This gives us 4
billion addresses to work with, which isn't really enough
◉ IPv6. Answer: uses 128 bits, 10^40 addresses
◉ canonical format. Answer: divide into 8 fields separated by :
each filed is 16 bits (4 hex digits 0000-FFFF)
omit leading 0's
compress the longest consecutive field of 0's. if a tie, leftmost
◉ Reading a Domain Name. Answer: each string corresponds to an
IP address. The string is case insensitive
partial map: strins -> IP addresses, the map is stored in DNS
Hierarchy separated by .'s, highest-lowest. Top level is com, net, edu
then goes to the left with no limit
◉ FQDN. Answer: fully qualified domain name
hostname + domain name = stdlinux + cse.ohio-state.edu