Evaluating Numerical Expressions

Help Questions

AP Computer Science A › Evaluating Numerical Expressions

Questions 1 - 10
1

What is the Unicode value for the letter "W"?

U+0057

U+0087

U+0047

U+005C``

U+007C

Explanation

The Unicode Standard is Java's attempt to simplify the translation of characters and symbols to input the computer can understand, while being able to work on all Java machines. The first 128 numbers (0-127, 0x0000-0x007F) are for basic Latin. Under this character encoding scheme, the letter 'W' is denoted by U+0057.

The standard for writing Unicode values is U+####, where the number is in hexadecimal format, not a base 10 number.

2

What is the Unicode value for the letter "W"?

U+0057

U+0087

U+0047

U+005C``

U+007C

Explanation

The Unicode Standard is Java's attempt to simplify the translation of characters and symbols to input the computer can understand, while being able to work on all Java machines. The first 128 numbers (0-127, 0x0000-0x007F) are for basic Latin. Under this character encoding scheme, the letter 'W' is denoted by U+0057.

The standard for writing Unicode values is U+####, where the number is in hexadecimal format, not a base 10 number.

3

What is the Unicode value for the letter "W"?

U+0057

U+0087

U+0047

U+005C``

U+007C

Explanation

The Unicode Standard is Java's attempt to simplify the translation of characters and symbols to input the computer can understand, while being able to work on all Java machines. The first 128 numbers (0-127, 0x0000-0x007F) are for basic Latin. Under this character encoding scheme, the letter 'W' is denoted by U+0057.

The standard for writing Unicode values is U+####, where the number is in hexadecimal format, not a base 10 number.

4

Consider the code below:

int a = 24, b = 17, c = 5, d = 7;

b = b % d + a / b;

a %= b;

a -= 12;

What is the value of a at the end of the code above?

Explanation

The easiest way to trace code like this is to provide running commentary in bold comments. See these below:

int a = 24, b = 17, c = 5, d = 7;

/*

The modulus (%) is the remainder of a division. So . . .

b % d = 17 % 7 = 3 (17 divided by 7 is 2 remainder 3.)

a / b = 1 (Remember, integer division truncates the decimal portion.)

Thus, we have:

b = 3 + 1 = 4

*/

b = b % d + a / b;

a %= b; // This is the same as a = a % d, which is a = 24 % 4 = 0 (No remainder)

a -= 12; // Remember that this is the same as a = a - 12, which is a = 0-12 or -12.

5

Consider the code below:

int a = 24, b = 17, c = 5, d = 7;

b = b % d + a / b;

a %= b;

a -= 12;

What is the value of a at the end of the code above?

Explanation

The easiest way to trace code like this is to provide running commentary in bold comments. See these below:

int a = 24, b = 17, c = 5, d = 7;

/*

The modulus (%) is the remainder of a division. So . . .

b % d = 17 % 7 = 3 (17 divided by 7 is 2 remainder 3.)

a / b = 1 (Remember, integer division truncates the decimal portion.)

Thus, we have:

b = 3 + 1 = 4

*/

b = b % d + a / b;

a %= b; // This is the same as a = a % d, which is a = 24 % 4 = 0 (No remainder)

a -= 12; // Remember that this is the same as a = a - 12, which is a = 0-12 or -12.

6

Consider the code below:

int a = 24, b = 17, c = 5, d = 7;

b = b % d + a / b;

a %= b;

a -= 12;

What is the value of a at the end of the code above?

Explanation

The easiest way to trace code like this is to provide running commentary in bold comments. See these below:

int a = 24, b = 17, c = 5, d = 7;

/*

The modulus (%) is the remainder of a division. So . . .

b % d = 17 % 7 = 3 (17 divided by 7 is 2 remainder 3.)

a / b = 1 (Remember, integer division truncates the decimal portion.)

Thus, we have:

b = 3 + 1 = 4

*/

b = b % d + a / b;

a %= b; // This is the same as a = a % d, which is a = 24 % 4 = 0 (No remainder)

a -= 12; // Remember that this is the same as a = a - 12, which is a = 0-12 or -12.

7

Evaluate the mathematical equation?

Explanation

You have to remember PEMDAS.

Multiplication and Division take precedence first

(double multiplied by an int equal a double)

Addition and Subtraction after

8

Evaluate the mathematical equation?

Explanation

You have to remember PEMDAS.

Multiplication and Division take precedence first

(double multiplied by an int equal a double)

Addition and Subtraction after

9

Evaluate the mathematical equation?

Explanation

You have to remember PEMDAS.

Multiplication and Division take precedence first

(double multiplied by an int equal a double)

Addition and Subtraction after

10

int x = 2893;

  1. What does the expression " x / 10 " evaluate to?
  2. What does the expression " x % 10 " evaluate to?
  1. 289
  2. 3
  1. 3
  2. 289
  1. 289.3
  2. 893
  1. 289.3
  2. 3
  1. 289
  2. 2000

Explanation

  1. 2893 / 10 = 289, since x is an int, it does not store the decimal value
  2. 2893 % 10 = 3 because the remainder of 2893/10 is 3
Page 1 of 3
Return to subject