Chapter 10 JAVA Flashcards

1
Q

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)

A

C. alpha ( / momentum - 12.4 )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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

A

D. A value that is acted upon by an operator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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

A

C. a + b

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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

A

B. cost per item: 0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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

A

C. 7.0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the result of evaluating the following expression?

-32 / 6
A. -2

B. -5

C. -5.3333

D. +6

A

B. -5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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.

A

C. An expression is a combination of literals, operators, variables, and parentheses used to calculate a value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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

A

D. x ) / (13

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the value of -32 % 6

A. 5

B. -5

C. 2

D. -2

A

D. -2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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

A

B. final double pi = 3.14159265358979 ;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly