CSE 2221 Midterm 2 Exam Questions and
answers
Declared Type - - Also known as static type
Left side of Declaration
Interface Type
Cannot change during runtime
- Object Type - - Also known as Dynamic type, because this part of a
variable can change during runtime
Right side of declaration statement
Constructor
Anything that implements interface can be used for this
Type used with overriden method calls
- How to Override a method? - - Must be a class extending a class
(e.g. myNaturalNumber extends NaturalNumber2)
Use @override
Keep same method header, change method body
- Extends - - Relationship between two classes or two interfaces
With classes, retains the method bodies
With interfaces, retains the method contracts
- Implements - - Relationship between class and interface
Class _______________s an interface
Class may do this with more than one interface
More than one class can do this with one interface
- What kind of variable is NaturalNumber? - - A reference type, points to an
object value
, - How do i initialize a natural number with a number bigger than the max
value of an int? - - Use another natural number, a string with said number,
or math to get there
- What is the default parameter mode when none is specified? - - Restores
Mode
- Restores - - Returns input variable to its original value at the end of the
method
- Updates - - Changes the value of the input variable based on its original
value
- Clears - - Returns the value of the input variable to a default value, usually
zero
- NaturalNumber Compareto Results - - positive if A > B
0 if A = B
Negative if A < B
- Replaces - - Changes the value of the input variable regardless of the
orgiinal value
- Immutable Reference - - Has a reference value and an object value
Variable value cannot be changed in a method cal]
Value can be reassigned, but not directly changed by a method call
Example: String, XMLTree
- Mutable Reference - - Has a reference value and an object value
- Primitive type - - Has a value that can be directly changed, the variable is
the value
Double, int, char, boolean
- Test cases should include - - Routine Cases
Challenging Cases
Boundary Cases
They also must satisfy the preconditions
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller Nursephil2023. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $8.49. You're not tied to anything after your purchase.