CSE 2221 Midterm 2 Prep 2025. | Exam Revision Questions And Correct
Answers | Graded A+ | 2025 Update |
what is a natural number - ANSWER- an integer greater than or equal to 0
in the instance method n.methodName(arguments); ______ is called the receiver and the
corresponding distinguished formal parameter has the name ______- - ANSWER- n; this
what does "#cat" mean - ANSWER- the previous value of cat
what does m.add(k) do - ANSWER- adds k to value of m (changes value of m but not value of
k)
what does m.subtract(k) do - ANSWER- subtracts k from value of m (changes value of m but
not of k)
what does m.multiply(k) do - ANSWER- multiplies m by value of k (changes value of m but
not of k)
what does NaturalNumber r = m.divide(k) do - ANSWER- divides m by k and returns the
remainder to variable r
what does m.copyFrom(k) do - ANSWER- copies value of k into value of m
what does int comp = m.compareTo(k) do - ANSWER- compares value of m to k; if m > k,
comp gets set to 1, if equal, comp = 0 and if less than, comp = -1
what does m.multiplyBy10(d) do - ANSWER- multiplies m by 10 then adds k
, what does int r = m.divideBy10() do - ANSWER- divides m by 10 and sets r equal to the
remainder
boolean z = m.isZero() - ANSWER- returns z to true if m is zero
what does m.clear() do - ANSWER- sets value of m to zero
m.transferFrom(k) - ANSWER- sets value of m = k and resets k to zero
String s = m.toString - ANSWER- returns the string version of m to s (ex: if m = 143, s = "143")
primitive types vs reference types - ANSWER- primitive types are boolean, char, int, double;
reference types are String, XMLTree, SimpleReader, etc.
primitive variable - ANSWER- variable of a primitive type (int, double, boolean, char)
reference variable - ANSWER- variable of a reference type (XMLTree, String)
reference value vs object value - ANSWER- object value is the actual value while reference
value is the memory address of the object
notation for reference value - ANSWER- triangle with arrow pointing to object value
when you do String s = t, changing the value of t ___________ - ANSWER- changes the value
of s
when doing NaturalNumber n = z, changing the value of n ________ - ANSWER- changes the
value of z
Answers | Graded A+ | 2025 Update |
what is a natural number - ANSWER- an integer greater than or equal to 0
in the instance method n.methodName(arguments); ______ is called the receiver and the
corresponding distinguished formal parameter has the name ______- - ANSWER- n; this
what does "#cat" mean - ANSWER- the previous value of cat
what does m.add(k) do - ANSWER- adds k to value of m (changes value of m but not value of
k)
what does m.subtract(k) do - ANSWER- subtracts k from value of m (changes value of m but
not of k)
what does m.multiply(k) do - ANSWER- multiplies m by value of k (changes value of m but
not of k)
what does NaturalNumber r = m.divide(k) do - ANSWER- divides m by k and returns the
remainder to variable r
what does m.copyFrom(k) do - ANSWER- copies value of k into value of m
what does int comp = m.compareTo(k) do - ANSWER- compares value of m to k; if m > k,
comp gets set to 1, if equal, comp = 0 and if less than, comp = -1
what does m.multiplyBy10(d) do - ANSWER- multiplies m by 10 then adds k
, what does int r = m.divideBy10() do - ANSWER- divides m by 10 and sets r equal to the
remainder
boolean z = m.isZero() - ANSWER- returns z to true if m is zero
what does m.clear() do - ANSWER- sets value of m to zero
m.transferFrom(k) - ANSWER- sets value of m = k and resets k to zero
String s = m.toString - ANSWER- returns the string version of m to s (ex: if m = 143, s = "143")
primitive types vs reference types - ANSWER- primitive types are boolean, char, int, double;
reference types are String, XMLTree, SimpleReader, etc.
primitive variable - ANSWER- variable of a primitive type (int, double, boolean, char)
reference variable - ANSWER- variable of a reference type (XMLTree, String)
reference value vs object value - ANSWER- object value is the actual value while reference
value is the memory address of the object
notation for reference value - ANSWER- triangle with arrow pointing to object value
when you do String s = t, changing the value of t ___________ - ANSWER- changes the value
of s
when doing NaturalNumber n = z, changing the value of n ________ - ANSWER- changes the
value of z