(TESTING REAL EXAM QUESTIONS) AND CORRECT
ANSWERS (MULTIPLE CHOICES) |COMPLETE
VERIFIED SOLUTIONS |ALREADY GRADED
A+ | 2025 BRAND NEW!!
Assume n is an int variable. Which Java expression is true
exactly when n is an
odd number, i.e., not divisible by 2, and should be used to
check for this
situation? (hint: don't forget negative
numbers!)
*a.* n % 2 ==
1
*b.* n % 2 !=
1
*c.* n % 2 ==
0
*d.* n % 2 !=
0
*e.* none of the above -
ANSWER-d
,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 - ANSWER-a
Which of the Stack methods will add an int to the top of x?
*a.* x.pop(int 42);
*b.* x.append(int 42);
*c.* x.enqueue(int 42);
*d.* x.top(int 42);
,*e.* x.push(int 42); - ANSWER-e
Which of the following are true of Sets?
1. There is no
empty set
2. There are no duplicate
elements
3. There is no order among the
elements
*a.* only 3 is
true
*b.* 1 and 3 are
true
*c.* 2 and 3 are
true
*d.* they are all
true
*e.* none are true -
ANSWER-c
What represents an ordered Java component?
*a.* { }
, *b.* < >
*c.* [ ]
*d.* ( )
*e.* " " - ANSWER-b
What represents an unordered Java component?
*a.* < >
*b.* [ ]
*c.* " "
*d.* { }
*e.* ( ) - ANSWER-d
What is the size and height of this XMLTree?
<?xml version="1.0" encoding="UTF-8"?>
<test class="CSE2221" midterm="1">
<question number="1" type="m-c">
<points>15</points>
<parts>5</parts>
</question>
<question number="5" type="coding" />
</test>