Download CSE 2221 Midterm 2 2025: RSS and NaturalNumber Solutions and more Exams Advanced Education in PDF only on Docsity!
CSE 2221 MIDTERM 2 2025 QUESTIONS
AND VERIFIED SOLUTIONS| ABSOLUTE
SUCCESS GUARANTEED.
- A textual format used on the web for "news feeds" or "web feeds" is... - Correct Answer-RSS
- Relationship of RSS to XML - Correct Answer-RSS 2.0 feed is well- formed XML
- What is the first line of code in every RSS feed? - Correct Answer-
- There are exactly how many channel nodes? - Correct Answer-One
- What three elements are required under channel? - Correct Answer- title, link and description
- Which one of the three required elements under channel, MUST have a child? - Correct Answer-link
- What can be a child of channel, apart from the three required tags? - Correct Answer-item
- What are the required children of every item tag? - Correct Answer-title OR description
- Which two children MUST have children - Correct Answer-link and pubDate
- What is the only child of the rss node? - Correct Answer-channel
- The ________ component family allows you to manipulate natural numbers - Correct Answer-NaturalNumber
- What is NaturalNumber's upper bound? - Correct Answer-There is no upper bound
- 3 methods in the Standard class - Correct Answer-clear newInstance transferFrom
- NaturalNumber-Kernel extends what? - Correct Answer-Standard
- NaturalNumber-Kernel ________ Standard - Correct Answer-extends
- What extends Standard - Correct Answer-NaturalNumber-Kernel
- Separating the ______ into their own interface means that these highly reused methods are described in exactly one place - Correct Answer- standard methods
- Separating the standard methods into their own interface means what?
- Correct Answer-That these methods are described in exactly one place
- "Separating the standard methods into their own interface means that these highly reused methods are described in exactly one place" What is this design goal called - Correct Answer-Single point of control over change
- The interface ___________ has all other methods that are convenient to have in the NaturalNumber component family - Correct Answer- NaturalNumber
- What are the methods inside of NaturalNumber called? - Correct Answer-Secondary methods
- Which methods are typically more "powerful"? NaturalNumber-Kernel or NaturalNumber? - Correct Answer-NaturalNumber methods
- Lower bound of NaturalNumber - Correct Answer- 0
- What are the four constructors for each implementation class? - Correct Answer-No-argument Constructor (no parameters) Copy Constructor (NaturalNumber n) Constructor from int (int i) Constructor from String (String s)
- What is n? NaturalNumber n = new NaturalNumber2(); - Correct Answer-n = 0;
- What is the receiver in this case? n.add(seven); - Correct Answer-n
- What is the method name in this case? n.add(seven); - Correct Answer-add
- What is the argument(s) in this case? n.add(seven); - Correct Answer-seven
- What method do you call when you want to ensure this = #this + n - Correct Answer-add(n)
- What is the return type and the argument(s) in add? - Correct Answer- void add(NaturalNumber n)
m = 10 k = 7 m.add(k) What is m and k? - Correct Answer-m = 17
k = 7
- What method do you call when you want to ensure this = #this - n - Correct Answer-subtract(n);
- What is the return type and the argument(s) in subtract? - Correct Answer-void subtract(NaturalNumber n)
m = 10 k = 7 m.subtract(k); What are m and k now? - Correct Answer-m = 3 k = 7
- What method do you call when you want to ensure this = #this * n? - Correct Answer-multiply(n);
- What is the return type and the argument(s) inside of multiply()? - Correct Answer-void multiply(NaturalNumber n)
What method do you call when you want to ensure this = #this ^ (p) - Correct Answer-power(p)
- What is the return type and the argument(s) of power()? - Correct Answer-void power(int p)
- What is required by the power function? - Correct Answer-p >= 0
m = 10 k = 7 m.power(k) What are m and k? - Correct Answer-m = 10^ k = 7
- What method do you use when you want to ensure this ^ (r) <= #this < (this + 1) ^ (r)? - Correct Answer-root(r)
- What is the return type and the argument(s) of root()? - Correct Answer-void root (int r)
m = 24 k = 2 m.root(k); What are m and k? - Correct Answer-m = 4 k = 2
m = 25 k = 2 m.root(k) What are m and k? - Correct Answer-m = 5 k = 2
- What method do you call when you want to ensure this = n? - Correct Answer-copyFrom(n)
- What is the return type and the argument(s) of copyFrom? - Correct Answer-void copyFrom(NaturalNumber n)
m = 10 k = 10 int i = m.compareTo(k); Is i positive, negative or zero? - Correct Answer-zero
- What method would you call if you wanted to ensure this = 10 * #this + k? - Correct Answer-multiplyBy10(k)
- What is the return type and the argument(s) of multiplyBy10()? - Correct Answer-void multiplyBy10(int i)
m = 10 k = 7 m.multiplyBy10(k) What are m and k? - Correct Answer-m = 107 k = 7
- What does #this represent? - Correct Answer-this BEFORE the method was called
- What method do you call if you want to ensure #this = 10 * this + [return] AND 0 <= [return] < 10 - Correct Answer- divideBy10()
- What is the return type and the argument(s) for divideBy10()? - Correct Answer-int divideBy10() m = 107 int k = m.divideBy10() What are m and k? - Correct Answer-m = 10 k = 7
- What method do you call if you want to ensure [return] = (this = 0)? - Correct Answer-isZero()
- What is the return type and the argument(s) of isZero()? - Correct Answer-boolean isZero() m = 10
m = 10 NaturalNumber k = m.newInstance(); What are m and k? - Correct Answer-m = 10 k = 0
- What method do you call when you want to ensure this = #n n = 0 - Correct Answer-transferFrom(n) m = 10 k = 7 m.transferFrom(k) What are m and k? - Correct Answer-m = 7 k = 0
- What method do you call when you want to ensure [return] = [the string representation of this] - Correct Answer-toString()
- What is the return type and the argument(s) of toString()? - Correct Answer-String toString()
- m = 10 String k = m.toString() What are k and m equal to? - Correct Answer-m = 10 k = "10"
- Java types are divided into two different categories - Correct Answer- Primitive types and reference types
- Define primitive types - Correct Answer-Built-in types
- Define reference types - Correct Answer-Types that were not built in
- How do primitive variables and reference variables differ? - Correct Answer-Primitive variables are simply just its value. Reference variables are a reference to an object that contains the value.
- What is the reference value? - Correct Answer-the memory address at which the object is stored
- Why have mutable types? - Correct Answer-Efficiency purposes
- How to check equality for reference types? - Correct Answer-.equals
- How to check equality for primitive types? - Correct Answer-== 25.1 A _______ is a group of similar variables, all of the same type and with systematically related names that involve special syntax using [...] - Correct Answer-array 25.1 What is an array? - Correct Answer-a group of similar variables, all of the same type, and with systematically related names that involve special syntax using [...] 25.1 What is an array element? - Correct Answer-A value that acts as a single variable of the type used in the declaration of the array e.g. a[0], a[1] 25.1 How to determine how many array elements are inside of an array? - Correct Answer-a.length
25.1 Are arrays primitive types or reference types? - Correct Answer- reference types 25.1 What happens when you compare two arrays using .equals()? - Correct Answer-It acts as == instead of .equals() 25.1 How should your compare two arrays to determine if they are equal? - Correct Answer-Utilizing the package java.util, use the static method, Arrays.deepEquals() 25.1 Determine if array a[] is equal to array b[] - Correct Answer- Arrays.deepEquals(a,b); returns true is they are equal 25.1 A recommended alternative to arrays - Correct Answer-java.util.List interface with ArrayList implementation 25.2 What are the two important features for the contracts in the APIs for OSU CSE components? - Correct Answer-Parameter modes Two stipulations (flashcard for that elsewhere)