Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 4 out of 38 pages
Exam (elaborations)

OSU CSE 2221 Final Review Exam Questions AND Correct Answers

Document preview thumbnail
Preview 4 out of 38 pages

OSU CSE 2221 Final Review Exam Questions AND Correct Answers

Content preview

OSU CSE 2221 Final Review Exam Questions AND Correct
Answers
a - ✔✔After execution of the following code, what are the declared
type (static type) and the object type (dynamic type) of nCopy?


NaturalNumber n = new NaturalNumber2( );
NaturalNumber nCopy = new NaturalNumber1L(n);


*a.* declared type is NaturalNumber, object type is NaturalNumber1L
*b.* declared type is NaturalNumber, object type is NaturalNumber2
*c.* declared type is NaturalNumber2, object type is
NaturalNumber1L
*d.* declared type is NaturalNumber1L, object type is
NaturalNumber2


a - ✔✔Consider the following code fragment:


int x = 8;
while ((x / 3) != 2) { x = x - 1; }


How many times will the body of the loop execute?


*a.* 0

,*b.* 1
*c.* 2
*d.* 3
*e.* the loop will never terminate


a - ✔✔Given the following code, which statement is true?


SimpleWriter out = new SimpleWriter1L( );
NaturalNumber n1 = new NaturalNumber1L(5);
NaturalNumber n2 = n1;
n2.decrement( );
out.println("n1 = " + n1 + ", n2 = " + n2);


*a.* will output "n1 = 4, n2 = 4"
*b.* will output "n1 = 5, n2 = 4"
*c.* will not compile
*d.* will result in a run-time error
*e.* none of the above


a - ✔✔Provided by the code calling the method:


*a.* argument

,*b.* variable
*c.* formal parameter
*d.* constant
*e.* expression


a - ✔✔What can you say about these two methods m1 & m2?


private static boolean m1(int x, int y) {
boolean result;
if (x>0 && y > 0) { result = false; }
else { result = true; }
return result;
}


private static boolean m2(int x, int y)
{ return !(x > 0 && y > 0); }


*a.* both return the same result for all values of x and y
*b.* they return different values of x and y
*c.* m1 contains syntax errors
*d.* m2 contains syntax errors
*e.* both have syntax errors

, a - ✔✔What is the value of k after this code completes?


int i = 0, j = 0, k = 0;
while (i < 3) {
i++;
j = 0;
while (j < 3) {
j++;
k = k + i + j;
}}


*a.* 36
*b.* 54
*c.* 9
*d.* 6


a - ✔✔What is the value of x after this statement?


double x = ;


*a.* 0.0

Document information

Uploaded on
October 30, 2025
Number of pages
38
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$12.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
ExamsCentre
3.7
(3)
Sold
13
Followers
0
Items
1709
Last sold
2 months ago


Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions