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

Exam (elaborations)

CSE 2221 Final Exam Review| Study Questions Solved 100% Correct

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

CSE 2221 Final Exam Review| Study Questions Solved 100% Correct

Preview 3 out of 25  pages

  • September 7, 2024
  • 25
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • CSE 2221
  • CSE 2221
avatar-seller
KenAli
CSE 2221 Final Exam Review| Study
Questions Solved 100% Correct

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

, b. when both a and b are false
c. when both a and b are true
d. when a is not equal to b - ANSWER c. when both a and b are true


Consider the following method header:
private static void setToZero (int x)
and the client code:
int number=10;
setToZero(number);
The value of variable number after the method call:
a. is guaranteed to be 0
b. is guaranteed to be 10
c. could be either 0 or 10, but nothing else

d. could be anything; there is not enough information to know - ANSWER b. is guaranteed to
be 10


What is the value of nums[1] +nums[3] just after you declare:
int[] nums={7,3,5,6};
a.12
b.9
c.4
d. It is impossible to tell - ANSWER b.9



Which line of code could be the body of a method that reports whether a point
with coordinates (x,y) is inside the square with sides of length 2 centered (1,1)?

a. return(Math.abs(x)<=1.0 &&Math.abs(y)<=1.0);
b. return(x<=2.0 && y<=2.0);
c. return (Math.abs(x-1.0)<=1.0 && Math.abs(y-1.0)<==1.0)

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