Question
Q10: Which of the following is not an error (either a syntax error or a logic error)? Neglecting to include an action in the body
Q10: Which of the following is not an error (either a syntax error or a logic error)?
- Neglecting to include an action in the body of a while statement that will eventually cause the condition to become false.
- Spelling a key word (such as while or if) with a capitalized first letter.
- Using a condition for a while statement that is initially false.
- An infinite loop.
Q11: How many times is the body of the loop below executed?
int counter;
counter = 1;
while ( counter < 20 )
{
// body of loop
counter = counter + 2;
} // end while
|
|
|
|
Q12: Which statement is true?
- Dividing two integers results in integer division.
- With integer division, any fractional part of the calculation is lost.
- With integer division, any fractional part of the calculation is truncated.
- All of the above.
Q13: In an expression containing values of the types int and double, the ________ values are ________ to ________ values for use in the expression.
- int, promoted, double.
- int, demoted, double.
- double, promoted, int.
- double, demoted, int.
Q14: Local variables must be ________.
- initialized when they are declared.
- initialized before their values are used in an expression.
- declared and initialized in two steps.
- declared at the top of the metho
Q15: Which statement is true?
- A while statement cannot be nested inside another while statement.
- An if statement cannot be nested inside another if statement.
- A while statement cannot be nested inside an if statement.
- None of the above is true.
Q16: Which of the following code segments does not increment val by 3:
- val += 3:
- val = val+1; val = val+1; val = val+1;
- c = 3; val = val + (c == 3 ? 2 : 3);
d. All of the above increment val by 3.
Q17: What does the expression x %= 10 do?
- Adds 10 to the value of x, and stores the result in x.
- Divides x by 10 and stores the remainder in x.
- Divides x by 10 and stores the integer result in x.
- None of the above.
Q18: What is the result value of c at the end of the following code segment?
int c = 8;
c++;
++c;
c %= 5;
|
|
|
|
Q19: Which of the following is not a primitive type?
a. char b. float
c. String d. int
Q20: Which primitive type can hold the largest value?
a. int b. long
c. float d. double
Q21: What is the size in bits of an int?
|
|
|
|
Q22: In Java graphics, coordinate units are measured in ________.
|
|
|
|
Q23: Keyword ________ indicates the inheritance relationship.
|
|
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started