CSE 1321 STUDY GUIDE EXAM 2026/2027 QUESTIONS AND
SOLUTIONS RATED A+
✔✔Conversion Techniques - ✔✔- Assignment conversion
Example: assign an int to a long
-Promotion
Example: divide an int by a double
- Casting
Example: assign a double to int
✔✔Explicit Type Casting - ✔✔Syntax:
(dataType)(expression)
Note: parentheses around the expression are optional if the expression consists of 1
variable
Useful for calculating averages:
double result = (double) 25/3;
double result = (double) total / count;
✔✔Expression evaluation follow - ✔✔operator precedent rule (order of operations).
✔✔The order of statement execution is called the - ✔✔flow of control
✔✔By default, execution is - ✔✔linear: one statement after another
✔✔A ------- allows us to choose which statements will be executed next: - ✔✔Selection
(conditional) statement
✔✔if - ✔✔if - block of code executes if a Boolean expression is true.
(selection statement)
✔✔if-else - ✔✔will execute one block of code if the Boolean expression is true, or
another if it is false.
(selection statement)
✔✔if-else-if - ✔✔tests a series of Boolean expressions and execute corresponding
block when it finds one that is true.
(selection statement)
✔✔switch - ✔✔lets the value of a variable determine where the program will branch to.
, ✔✔Relational Operators - ✔✔Create a true or false using a relational operator:
> greater than
< less than
== equals
! not
!= not equal
>= greater than or equal
<= less than or equal
✔✔!
!= - ✔✔not not equal to (relational operators)
✔✔Logical Operators - ✔✔Boolean expressions can also use the following logical
operators:
Logical NOT
Logical AND
Logical OR
Exclusive OR
✔✔Mathematical operators have ------ than the Relational and Logical operators -
✔✔higher precidence
✔✔&&
I I - ✔✔And
Or
(logical operators)
✔✔The ------- provides another way to decide which statement to execute next -
✔✔switch statement
✔✔The switch statement evaluates an --------, then attempts to match the result to one
of several possible - ✔✔expression, cases (cases)
-Each case contains a value and a list of statements
-The flow of control transfers to statement associated with the first case value that
matches
✔✔Often a ------ is used as the last statement in each case's statement list - ✔✔break
statement
✔✔A break statement causes control to transfer to the - ✔✔end of the switch statement.
-If a break statement is not used, the flow of control will continue into the next case
✔✔Default Case - ✔✔-A switch statement can have an optional default case
SOLUTIONS RATED A+
✔✔Conversion Techniques - ✔✔- Assignment conversion
Example: assign an int to a long
-Promotion
Example: divide an int by a double
- Casting
Example: assign a double to int
✔✔Explicit Type Casting - ✔✔Syntax:
(dataType)(expression)
Note: parentheses around the expression are optional if the expression consists of 1
variable
Useful for calculating averages:
double result = (double) 25/3;
double result = (double) total / count;
✔✔Expression evaluation follow - ✔✔operator precedent rule (order of operations).
✔✔The order of statement execution is called the - ✔✔flow of control
✔✔By default, execution is - ✔✔linear: one statement after another
✔✔A ------- allows us to choose which statements will be executed next: - ✔✔Selection
(conditional) statement
✔✔if - ✔✔if - block of code executes if a Boolean expression is true.
(selection statement)
✔✔if-else - ✔✔will execute one block of code if the Boolean expression is true, or
another if it is false.
(selection statement)
✔✔if-else-if - ✔✔tests a series of Boolean expressions and execute corresponding
block when it finds one that is true.
(selection statement)
✔✔switch - ✔✔lets the value of a variable determine where the program will branch to.
, ✔✔Relational Operators - ✔✔Create a true or false using a relational operator:
> greater than
< less than
== equals
! not
!= not equal
>= greater than or equal
<= less than or equal
✔✔!
!= - ✔✔not not equal to (relational operators)
✔✔Logical Operators - ✔✔Boolean expressions can also use the following logical
operators:
Logical NOT
Logical AND
Logical OR
Exclusive OR
✔✔Mathematical operators have ------ than the Relational and Logical operators -
✔✔higher precidence
✔✔&&
I I - ✔✔And
Or
(logical operators)
✔✔The ------- provides another way to decide which statement to execute next -
✔✔switch statement
✔✔The switch statement evaluates an --------, then attempts to match the result to one
of several possible - ✔✔expression, cases (cases)
-Each case contains a value and a list of statements
-The flow of control transfers to statement associated with the first case value that
matches
✔✔Often a ------ is used as the last statement in each case's statement list - ✔✔break
statement
✔✔A break statement causes control to transfer to the - ✔✔end of the switch statement.
-If a break statement is not used, the flow of control will continue into the next case
✔✔Default Case - ✔✔-A switch statement can have an optional default case