CSE 2221 Midterm 2 Guide 2025. | Exam Revision Questions And Correct
Answers | Graded A+ | 2025 Update |
variables - ANSWER- A named storage location in memory that holds a value. In Java,
variables must be declared with a type before use.
primitive types - ANSWER- Basic data types that store actual values, not references. Examples:
int (integer), double (floating point), boolean (true/false), char (single character).
reference types - ANSWER- Variables that store memory addresses rather than actual values.
Examples: String, arrays, objects.
arithmetic operators - ANSWER- Symbols used to perform mathematical operations.
Examples: + (addition), - (subtraction), * (multiplication), / (division), % (modulus, remainder).
comparison operators - ANSWER- Symbols used to compare values. Examples: == (equal), !=
(not equal), > (greater than), < (less than), >= (greater than or equal), <= (less than or equal).
logical operators - ANSWER- Operators used in boolean expressions. Examples: && (AND,
both conditions must be true), || (OR, at least one condition must be true), ! (NOT, negates a
boolean value).
assignment operators - ANSWER- Used to assign values to variables. Examples: = (assign),
+= (add and assign), -= (subtract and assign), *= (multiply and assign), /= (divide and assign).
modulo operator (%) - ANSWER- Returns the remainder of a division operation. Example: 10
% 3 results in 1.
if statement - ANSWER- A control flow statement that executes a block of code only if a
specified condition is true.
, if-else statement - ANSWER- An extension of the if statement that provides an alternate block
of code to execute if the condition is false.
nested if - ANSWER- An if statement inside another if statement, used to check multiple
conditions.
switch statement - ANSWER- A control structure that allows multiple possible execution paths
based on the value of a variable. Uses case labels and a default case.
for loop - ANSWER- A loop that executes a block of code a fixed number of times. Syntax:
for(initialization; condition; update) { // code }.
while loop - ANSWER- A loop that continues to execute as long as the specified condition is
true.
do-while loop - ANSWER- A loop that executes at least once before checking the condition,
ensuring the body runs at least one time.
break statement - ANSWER- Used to exit a loop or switch statement immediately.
continue statement - ANSWER- Skips the current iteration of a loop and moves to the next
iteration.
static method - ANSWER- A method associated with a class rather than an instance. Called
using ClassName.methodName(). Example: Math.sqrt(25).
instance method - ANSWER- A method that operates on an instance of a class. Called using
objectName.methodName().
Answers | Graded A+ | 2025 Update |
variables - ANSWER- A named storage location in memory that holds a value. In Java,
variables must be declared with a type before use.
primitive types - ANSWER- Basic data types that store actual values, not references. Examples:
int (integer), double (floating point), boolean (true/false), char (single character).
reference types - ANSWER- Variables that store memory addresses rather than actual values.
Examples: String, arrays, objects.
arithmetic operators - ANSWER- Symbols used to perform mathematical operations.
Examples: + (addition), - (subtraction), * (multiplication), / (division), % (modulus, remainder).
comparison operators - ANSWER- Symbols used to compare values. Examples: == (equal), !=
(not equal), > (greater than), < (less than), >= (greater than or equal), <= (less than or equal).
logical operators - ANSWER- Operators used in boolean expressions. Examples: && (AND,
both conditions must be true), || (OR, at least one condition must be true), ! (NOT, negates a
boolean value).
assignment operators - ANSWER- Used to assign values to variables. Examples: = (assign),
+= (add and assign), -= (subtract and assign), *= (multiply and assign), /= (divide and assign).
modulo operator (%) - ANSWER- Returns the remainder of a division operation. Example: 10
% 3 results in 1.
if statement - ANSWER- A control flow statement that executes a block of code only if a
specified condition is true.
, if-else statement - ANSWER- An extension of the if statement that provides an alternate block
of code to execute if the condition is false.
nested if - ANSWER- An if statement inside another if statement, used to check multiple
conditions.
switch statement - ANSWER- A control structure that allows multiple possible execution paths
based on the value of a variable. Uses case labels and a default case.
for loop - ANSWER- A loop that executes a block of code a fixed number of times. Syntax:
for(initialization; condition; update) { // code }.
while loop - ANSWER- A loop that continues to execute as long as the specified condition is
true.
do-while loop - ANSWER- A loop that executes at least once before checking the condition,
ensuring the body runs at least one time.
break statement - ANSWER- Used to exit a loop or switch statement immediately.
continue statement - ANSWER- Skips the current iteration of a loop and moves to the next
iteration.
static method - ANSWER- A method associated with a class rather than an instance. Called
using ClassName.methodName(). Example: Math.sqrt(25).
instance method - ANSWER- A method that operates on an instance of a class. Called using
objectName.methodName().