Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 3 out of 17 pages
Exam (elaborations)

CSE 2221 Midterm 2 Questions and Correct Answers

Document preview thumbnail
Preview 3 out of 17 pages

CSE 2221 Midterm 2 Questions and Correct Answers

Content preview

1 | Page



cse 2221 midterm 2 Questions and Correct
Answers
what is the definition of the size of a tree? Ans: # of nodes in a
tree

what is the definition of the height of a tree? Ans: 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? Ans:
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? Ans: [0, ∞)
technically limited by memory though

what is the benefit of using the String constructor over the int
constructor? Ans: int has a limit while Sytring has a much, much
longer limit

what types of methods are in the NaturalNumber interface(s)? Ans:
instance methods




© 2025 All rights reserved

, 2 | Page


if I write "nn.isZero();" what is "nn" called? Ans: receiver

what does "@ensures this = #this + 1" mean in a method contract?
Ans: 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? Ans: yes, object value changes

when should you use copyFrom over transferFrom? Ans: 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)"? Ans: any
value x where x > 0 (i.e. a positive number)

in the function call "nn.multiplyBy10(k)", what is "k" for? Ans:
adding to ones place after multiplying

what are the kernel methods? Ans: isZero, multiplyBy10,
divideBy10

very essential methods to be used in all NaturalNumber objects

what is the default value of a NaturalNumber? Ans: 0

what is the resulting object value of the argument passes to a
transferFrom call? Ans: 0


© 2025 All rights reserved

, 3 | Page


what are reference types associated with? Ans: objects

is String a primitive or reference type? Ans: reference

is the value of a primitive type the actual value or is it a memory
address? Ans: actual

is the value of a reference type the actual value or is it a memory
address? Ans: memory

how many values does a reference type have? what are they? Ans:
2 - reference value and object value

draw the representation for the line "String myStr = "No class until
March 30th lol";" Ans: my Str triangle arrow to "No class until
March 30th lol" circled

draw the representation for the line "naturalNumber myNN = new
NaturalNumber2(400 + 55);"




what is the object value of the line of code? Ans: MyNN triangle
arrow to 455 in rectangle




455



© 2025 All rights reserved

Document information

Uploaded on
November 5, 2025
Number of pages
17
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$13.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Axpert
3.8
(127)
Sold
573
Followers
168
Items
29738
Last sold
1 day ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions