100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
CSE 2221 Final Exam Review/22 Complete Q’s and A’s $8.49   Add to cart

Exam (elaborations)

CSE 2221 Final Exam Review/22 Complete Q’s and A’s

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

CSE 2221 Final Exam Review/22 Complete Q’s and A’s

Preview 2 out of 6  pages

  • September 26, 2024
  • 6
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • CSE 2221
  • CSE 2221
avatar-seller
Nursephil2023
CSE 2221 Final Exam Review/22 Complete Q’s and
A’s
For a method formal parameter p, which parameter mode guarantees that
#p cannot appear n the ensures clause for the method's contract?
a. clears
b. replaces
c. restores
d. updates - - B. replaces

- You may reason about the behavior of Java code involving immutable
types exactly as if they were primitive types because:
a. "Immutable" and "primitive" are synonyms; there is no difference between
them
b. Computations involving immutable types are just as efficient as those
involving primitive types
c. Aliasing, which can happen with immutable types but not primitive types,
cannot cause trouble because object values for immutable types cannot be
changed
d. In any code where an immutable type is used in a way where it would not
behave like a primitive type, it causes a Java compile-time error - - C.
Aliasing

- Assume n is an int variable. Which Java expression is true exactly when n is
an odd number (not divisible by 2) and should be used to check for this
situation?
a. n%2==0
b. n%2!=0
c. n%2==1
d. n%2!=1 - - b. n%2!=0

- what are the values of str and num after the call to foo?
private static void foo(String s, NaturalNumber n){
s="Columbus, " +s;
n=new NaturalNumber2(43210);
}
...String str = "Ohio";
NaturalNumber num=new NaturalNumber2(314);
foo(str,num);
a. str="Ohio", num=314
b. str="Columbus, Ohio", num=314
c. str="Ohio", num=43210
d. str="Columbus, Ohio", num=43210 - - c. str="Ohio", num=314

- What are the values of array and index after the call to bar?

, private static void bar(int[] a, int i){
a[i]++;
i++;
}
...
int[] array={1,2,3,4};
int index=1;
bar(array,index);

a. array={1,2,3), index=1
b. array={1,2,3), index=2
c. array={1,3,3), index=1
d. array={1,3,3), index=2 - - c. array={1,3,3), index=1

- A type is an immutable type if:
a. It is illegal to copy a reference of that type, so there can be no aliasing.
b. For every instance method of that type, this and every other parameter of
that type is a restores-mode parameter
c. That type has a no-argument constructor.
d. A function method may not return a result of that type. - - b. For every
instance method of that type, this and every other parameter of that type is
a restores-mode parameter

- Which of the following test cases should not be performed?
a. routine or otherwise trivially simple test cases
b. test cases that would cause no change to parameters
c. boundary cases, based on the variables passed in
d. test cases which do not meet method preconditions - - d. test cases which
do not meet method preconditions

- Which is true of JUnit testing when the unit under test is a single method?
A. Very thorough JUnit testing can prove the correctness of the method body.
b. JUnit testing is generally considered an expensive waste of time in
industry
c. A single JUnit test case can show the presence of a defect in the method
body.
d. A single JUnit test case can show the absence of defects in the method
body, at least for the particular choice of inputs in that test case - - c. A
single JUnit test case can show the presence of a defect in the method body.

- After execution of the following code, what are the declared type (static
type) and the object type (dynamic type) of nCopy?
NaturalNumber n = new NaturalNumber1L();
NauturalNumber nCopy=new NaturalNumber2();
a. Declared type is NaturalNumber, object type is NaturalNumber1L
b. Declared type is NaturalNumber, object type is NautralNumber2

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 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.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

76945 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
$8.49
  • (0)
  Add to cart