100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
CSE 2221 Exam Study Guide | Study Questions with 100% Correct Verified Answers $13.24   Add to cart

Exam (elaborations)

CSE 2221 Exam Study Guide | Study Questions with 100% Correct Verified Answers

 8 views  0 purchase
  • Course
  • CSE 2221
  • Institution
  • CSE 2221

CSE 2221 Exam Study Guide | Study Questions with 100% Correct Verified Answers

Preview 2 out of 15  pages

  • September 7, 2024
  • 15
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • CSE 2221
  • CSE 2221
avatar-seller
KenAli
CSE 2221 Exam Study Guide | Study
Questions with 100% Correct Verified
Answers

Parameter Modes - ANSWER There are 4 parameter modes, each of which indicates a
possible way that a method might change the value of the corresponding argument.
Parameter modes help in 3 ways:

1) concisely summarize which arguments might have their values modified by a call
2) make requirements/ensures clauses shorter
3) alllow us to perform sanity checks of contracts against simple errors



Repeated Arguments - ANSWER The reciever is an argument: the reference value of the
reciever of a call (to an instance method) is copied to the formal parameter of this. Hence,
there is a repeated argument if the reciever is also passed as another argument to such a call.
Never pass any variable of a mutable reference type as an argument twice or more to a
single method call.



Clears Mode - ANSWER Upon return from a method call, a clear-mode parameter has an initial
value for its type, i.e., a value that an assignment of the no-argument constructor could give it.
This is equivalent to adding "and = [an initial value for its type] to the ensures clause]. A
clears-mode parameter should not appear in the ensures clause except as #x

, Restores Mode - ANSWER Upon return from a method call, a restores-mode parameter once
again has its incoming value. Equivalent to adding, e.g., ...and x = #x to the ensures clauss. An
old restores-mode parameter, e.g. #x should not appear in the ensures clause. This is the
default parameter mode, so if a parameter is not listed with some other mode then its mode
is restores.



Parameter Passing: References vs Parameters - ANSWER Just as the assignment operator copies
reference values, parameter passing to method calls copies reference values. The reference
values of the arguments are copied into the formal parameters to initialize them at the time of
the call. Upon return, nothing is copied back except the returned value of the method (if any),
and here too the reference value is coped back.



Equality Checking: References vs Parameters - ANSWER Just as the assignment operator =
copies reference values, and parameter passing to method calls copies reference values, the
equality operator == compares reference values. Since comparing object values is often what
you want instead, the equals method compares object values.



Aliasing - ANSWER When 2 reference variables contain the same reference value i.e.
two triangles pointing to the same oval, or one object with 2 references to it


Distinguished Formal Parameter - ANSWER Instance methods are called as follows:
n.methodName(arguments)

n is reciever; for all instance methods, the corresponding distinguished formal
parameter implicitly has the name this



Reciever - ANSWER Instance methods are called as follows: n.methodName(arguments).
Where n is called the reciever



Object value - ANSWER The object value is the mathematical model value of the object
the reference points to

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

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

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

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 KenAli. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $13.24. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

79271 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$13.24
  • (0)
  Add to cart