1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
Revise later
SpaceTo flip
If confident
All Flashcards
What is an assignment operator?
Evaluates the expression on the right and stores the result in the variable on the left.
What is integer division?
Division that returns only the whole number quotient (truncates the decimal).
What is double division?
Division that returns the actual quotient as a decimal.
What is the modulo operator?
The modulo operator (%) gives you the remainder of a division.
What is PEMDAS/BODMAS?
The standard order of mathematical operations: Parentheses, Exponents, Multiplication and Division, Addition and Subtraction.
What is the `int` data type?
A data type representing integers (whole numbers).
What is the `double` data type?
A data type representing floating-point numbers (numbers with decimal points).
What is a variable?
A named storage location in memory that can hold a value.
What is an expression?
A combination of variables, operators, and values that evaluates to a single value.
What is truncation?
Removing the decimal portion of a number, effectively rounding it down to the nearest integer.
What is the value of `a` after: `int a = 5 / 2;`?
a is 2.
What is the value of `b` after: `double b = 5 / 2.0;`?
b is 2.5.
What is the value of `c` after: `int c = 10 % 3;`?
c is 1.
What is the value of `d` after: `int d = 3 + 4 / 3 * (4-1);`?
d is 6.
What is the value of `e` after: `double e = (3 * 5 / 2) / (2.0 + 8);`?
e is 0.7.
What is the value of `f` after: `int f = 4 % 3 + 2 * 5 / 4;`?
f is 3.
What is the value of `g` after: `int g = (3 * 5 / 2) / (2 + 8);`?
g is 0.
What is the output of: `int x = 7; int y = x++; System.out.println(y);`?
7
What is the output of: `int x = 7; int y = ++x; System.out.println(y);`?
8
What is the value of `result` after: `int a = 5; double b = 2.5; double result = a + b;`?
result is 7.5
What is the result of an `int` operation with another `int`?
The result is an `int`.
What is the result of an operation with at least one `double`?
The result is a `double`.
What does a smaller number % a larger number return?
The smaller number.
How does Java handle order of operations?
Java follows PEMDAS/BODMAS, with modulo having the same precedence as multiplication and division.
What happens to the decimal part in integer division?
The decimal part is truncated (removed).
What is the purpose of the `=` operator?
Assigns the value on the right-hand side to the variable on the left-hand side.
What is the difference between `score++` and `++score`?
`score++` increments after evaluation, `++score` increments before.
Why is understanding data types crucial in expressions?
Data types determine the type of result and how operations are performed (e.g., integer vs. double division).
What is the role of parentheses in expressions?
Parentheses dictate the order of operations, ensuring certain operations are performed before others.
What is the significance of the modulo operator in determining divisibility?
If `a % b` is 0, then `a` is divisible by `b`.