CSE 2221 Midterm Exam 2 Prep 2025. | Exam Revision Questions And
Correct Answers | Graded A+ | 2025 Update |
what is the definition of the size of a tree? - ANSWER- # of nodes in a tree
what is the definition of the height of a tree? - ANSWER- longest path from root to leaf in a
tree (largest # of nodes)
what is the definition of a path? what is the length of a path? - ANSWER- a series of nodes
connected by edges where each node is a parent or child of another
length is the # in a path
what is the value range of a NaturalNumber? - ANSWER- [0, ∞) technically limited by memory
though
what is the benefit of using the String constructor over the int constructor? - ANSWER- int has
a limit while Sytring has a much, much longer limit
what types of methods are in the NaturalNumber interface(s)? - ANSWER- instance methods
if I write "nn.isZero();" what is "nn" called? - ANSWER- receiver
what does "@ensures this = #this + 1" mean in a method contract? - ANSWER- new value of
this will be equal to the old value of this plus one
if I write "nn.increment()", does anything change about "nn"? what changes? - ANSWER- yes,
object value changes
, when should you use copyFrom over transferFrom? - ANSWER- if you have x.copyFrom(y),
this says you will still need y at its current value later in the code
if n1 > n2, what is the result of "n1.compareTo(n2)"? - ANSWER- any value x where x > 0 (i.e.
a positive number)
in the function call "nn.multiplyBy10(k)", what is "k" for? - ANSWER- adding to ones place
after multiplying
what are the kernel methods? - ANSWER- isZero, multiplyBy10, divideBy10
very essential methods to be used in all NaturalNumber objects
what is the default value of a NaturalNumber? - ANSWER- 0
what is the resulting object value of the argument passes to a transferFrom call? - ANSWER-
0
what are reference types associated with? - ANSWER- objects
is String a primitive or reference type? - ANSWER- reference
is the value of a primitive type the actual value or is it a memory address? - ANSWER- actual
is the value of a reference type the actual value or is it a memory address? - ANSWER- memory
how many values does a reference type have? what are they? - ANSWER- 2 - reference value
and object value
Correct Answers | Graded A+ | 2025 Update |
what is the definition of the size of a tree? - ANSWER- # of nodes in a tree
what is the definition of the height of a tree? - ANSWER- longest path from root to leaf in a
tree (largest # of nodes)
what is the definition of a path? what is the length of a path? - ANSWER- a series of nodes
connected by edges where each node is a parent or child of another
length is the # in a path
what is the value range of a NaturalNumber? - ANSWER- [0, ∞) technically limited by memory
though
what is the benefit of using the String constructor over the int constructor? - ANSWER- int has
a limit while Sytring has a much, much longer limit
what types of methods are in the NaturalNumber interface(s)? - ANSWER- instance methods
if I write "nn.isZero();" what is "nn" called? - ANSWER- receiver
what does "@ensures this = #this + 1" mean in a method contract? - ANSWER- new value of
this will be equal to the old value of this plus one
if I write "nn.increment()", does anything change about "nn"? what changes? - ANSWER- yes,
object value changes
, when should you use copyFrom over transferFrom? - ANSWER- if you have x.copyFrom(y),
this says you will still need y at its current value later in the code
if n1 > n2, what is the result of "n1.compareTo(n2)"? - ANSWER- any value x where x > 0 (i.e.
a positive number)
in the function call "nn.multiplyBy10(k)", what is "k" for? - ANSWER- adding to ones place
after multiplying
what are the kernel methods? - ANSWER- isZero, multiplyBy10, divideBy10
very essential methods to be used in all NaturalNumber objects
what is the default value of a NaturalNumber? - ANSWER- 0
what is the resulting object value of the argument passes to a transferFrom call? - ANSWER-
0
what are reference types associated with? - ANSWER- objects
is String a primitive or reference type? - ANSWER- reference
is the value of a primitive type the actual value or is it a memory address? - ANSWER- actual
is the value of a reference type the actual value or is it a memory address? - ANSWER- memory
how many values does a reference type have? what are they? - ANSWER- 2 - reference value
and object value