Exam Questions And Correct Answers (Verified Answers)
Already Graded A+ | Newest Exam Version | Just
Released!!
Which of the following best describes the condition sunder
which methodOne and methodTwo return the same value??
A. when a and b are both even
B. when a and b are both odd
C. when a is even and b is odd
D. when a % b is equal to zero
E. when a % b is equal to one - ANSWER-D. when a % b is equal
to zero
Consider the following code segments, which are each
intended to convert grades from a 100-point scale to a 4.0-point
scale and print the result. A grade of 90 or above should yield a
3.0, a grade of 80 to 89 should yield a 3.0, a grade of 70 to 79
should yield a 2.0, and any grade lower than 70 should yield a
0.0.
Assume that grade is an int variable that has be
properly declared and
initialized
.
,Code Segment I
double point = 0.0;
if (grade > 89)
{
points += 4.0;
}
if (grade > 79)
{
points += 3.0;
}
if (grade > 69)
{
points += 2.0;
}
else (grade > 70)
{
points += 0.0;
}
System.out.println(points);
Code Segment II
double point = 0.0;
if (grade > 89)
{
points += 4.0;
}
if (grade > 79)
{
points += 3.0;
, }
if (grade > 69)
{
points += 2.0;
}
else (grade < 70)
{
points += 0.0;
}
System.out.println(points)
;
which of the following statements correctly compares the
values printed by the two methods?
Consider the follo wing code segment in which int variable x
has been p roperly declared and initialized. if ( x % 2 == 1)
Sy stem.out.println("YES");
else
{
A. The two co - ANSWER-A. The two code segments print the
same value only when grade is below 80.
{