Evaluating Numerical Expressions
Help Questions
AP Computer Science A › Evaluating Numerical Expressions
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.
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.
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.
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.
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.
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.
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
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
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
int x = 2893;
- What does the expression " x / 10 " evaluate to?
- What does the expression " x % 10 " evaluate to?
- 289
- 3
- 3
- 289
- 289.3
- 893
- 289.3
- 3
- 289
- 2000
Explanation
- 2893 / 10 = 289, since x is an int, it does not store the decimal value
- 2893 % 10 = 3 because the remainder of 2893/10 is 3