Chapter 9 JAVA Flashcards
Which one of the following is a reserved word?
A. apple
B. 7up
C. grandTotal
D. boolean
D. boolean
Which one of the following is NOT a correct variable name?
A. 2bad
B. zero
C. theLastValueButOne
D. year2000
A. 2bad
Which one of the following declarations is NOT correct?
A. double duty;
B. float loan;
C. boolean value = 12;
D. int start = 34, end = 99;
C. boolean value = 12;
What does the following program output?
public class question4 { public static void main ( String[] args ) { int unitCost = 8; int items = 5; System.out.println("total cost: " + (unitCost * items) ); } } A. total cost: + 40
B. total cost: 8*5
C. total cost: 40
D. “total cost: “ 40
C. total cost: 40
Which of the following shows the syntax of an assignment statement?
A. variableName = expression;
B. expression = expression;
C. expression = variableName;
D. dataType = variableName;
A. variableName = expression;
Which of the following shows the syntax of an assignment statement?
A. variableName = expression;
B. expression = expression;
C. expression = variableName;
D. dataType = variableName;
A. variableName = expression;
What are the two steps that take place when an assignment statement is executed?
A. (i) Evaluate the Expression, and (ii) Store the value in the variable.
B. (i) Store the value in the variable, and (ii) Evaluate the Expression.
C. (i) Reserve memory , and (ii) fill it with a number.
D. (i) Evaluate the variable, and (ii) store the results.
A. (i) Evaluate the Expression, and (ii) Store the value in the variable.
What is an expression?
A. The same thing as a statement.
B. An expression is a list of statements that make up a program
C. An expression is a combination of literals, operators, variables, and parentheses used to calculate a value.
D. An expression is a number expressed in digits.
C. An expression is a combination of literals, operators, variables, and parentheses used to calculate a value.
Which one of the following expressions is NOT correct?
A. 5 + 4
B. (5 * 4)/2
C. (-12 + (13 + 7)/2 ) * 4
D. -12 + (13 + 7)/2 ) * 4
D. -12 + (13 + 7)/2 ) * 4
Which of the following expressions is NOT correct?
A. (34 - 86) / 3
B. (34 - 86) / -3
C. 34 - 86) / (23 - 3 )
D. ( (34 - 86) / (23 + 3 ) )
C. 34 - 86) / (23 - 3 )
What is the value of the following expression:
(2 - 6) / 2 + 9
A. 7
B. 8
C. 9
D. 10
A. 7