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

Exam (elaborations)

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

 0 view  0 purchase
  • Course
  • CSE 2221
  • Institution
  • CSE 2221

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

Preview 3 out of 26  pages

  • September 7, 2024
  • 26
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • CSE 2221
  • CSE 2221
avatar-seller
KenAli
CSE 2221 Final Exam Review| Study
Questions with 100% Correct Verified
Answers
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 - ANSWER 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(n);
a. Declared type is NaturalNumber, object type is NaturalNumber1L
b. Declared type is NaturalNumber, object type is NautralNumber2
c. Declared type is NaturalNumber2, object type is NaturalNumber1L

,d. Declared type is NaturalNumber2, object type is NaturalNumber - ANSWER b. Declared type
is NaturalNumber, object type is NautralNumber2


If you write class C implements interface I, the Java compiler checks:
a. Whether I overrides all the methods of C
b. Whether C inherits all the methods of I
c. Whether each method in I has a method body in C

d. Whether each method body in C is a correct implementation of the contract for that method
in I - ANSWER c. Whether each method in I has a method body in C


Consider the following code:
int x=80;
if (x>70){
x=40;
}else if (x<90){
x=20;
}
if (x>30){

x=60;
}
a. 20
b. 40
c. 60
d. 80 - ANSWER C. 60


In design-by-contract, the code responsible for making sure the precondition (requires clause)
is true when a method is called is:
a. the code that implements the method

, b. the client code that calls the method
c. both the client and the implementation code

d. neither the client nor the implementation code - ANSWER b. the client code that calls
the method



Suppose you want want to set teh double variable value to a random real number
uniformly distributed in the interval [-2.0, 2.0). You have made the following declaration:
Random r=new Random1L();

noting that r.nextDouble() returns a random real number uniformly distributed in the interval
[0.0, 1.0). Which statement will set value to the desired result?
a. value=-2.0 * r.nextDouble();
b. value=-2.0+2.0*r.nextdouble();
c. value= 4.0*r.nextDouble()-2.0;
d. value=-2.0 *r.nextDouble() + 2.0*r.nextDouble() - ANSWER c. value= 4.0*r.nextDouble()-2.0;


Consider the following method header:
private static boolean isPrime(int x)
and the call:
boolean answer=isPrime(number);
In this context:
a. x is a formal parameter and number is an argument(or actual parameter)
b. x is an argument (or actual parameter) and number is a formal parameter

c. x is a local variable and number is a distinguished variable

d. both x and number are global variables - ANSWER a. x is a formal parameter and number is
an argument(or actual parameter)


If a and b are boolean variables, when does the expression (!a||!b) evaluate to false?
a. when either a or b is true, but not both

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)

73243 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