Chapter 10 JAVA Flashcards
Which one of the following is NOT a correct arithmetic expression?
A. alpha
B. (alpha / momentum) - 12.4
C. alpha ( / momentum - 12.4 )
D. ((alpha / momentum) - 12.4)
C. alpha ( / momentum - 12.4 )
What is an operand?
A. Another name for number
B. Another name for integer
C. One of the arithmetic symbols like *, +, -, and /
D. A value that is acted upon by an operator
D. A value that is acted upon by an operator
Assume the following declarations:
short a=12 ;
int b=33 ;
float x = 2.3;
double y = 3.14;
Which one of the following expressions will NOT be evaluated using double precision floating point?
A. a + x
B. 1.5 + 8.6
C. a + b
D. x / y
C. a + b
What does the following program output?
public class question4 { public static void main ( String[] args ) { int totalCost = 6; int items = 12; System.out.println("cost per item: " + totalCost/items ); } } A. cost per item: .5
B. cost per item: 0
C. cost per item: 1
D. cost per item: +6/12
B. cost per item: 0
What is the result of evaluating the following expression?
( 1/2 + 3.5) * 2.0
A. 8.0
B. 8
C. 7.0
D. 0
C. 7.0
What is the result of evaluating the following expression?
-32 / 6
A. -2
B. -5
C. -5.3333
D. +6
B. -5
What is an expression?
A. An expression is 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.
Given the following expression:
(a - x)/(13 - z)
Which of the following is NOT a subexpression?
A. (a - x)
B. (13 - z)
C. a - x
D. x ) / (13
D. x ) / (13
What is the value of -32 % 6
A. 5
B. -5
C. 2
D. -2
D. -2
Which of the following declarations works for the constant pi (assume that the numerical value is correct)?
A. final pi = 3.14159265358979 ;
B. final double pi = 3.14159265358979 ;
C. constant double pi = 3.14159265358979 ;
D. double pi = 3.14159265358979
B. final double pi = 3.14159265358979 ;