CSE 1321 FINAL EXAMS 2026/2027 QUESTIONS AND
SOLUTIONS RATED A+
✔✔In the following code, PRINT(num) is an example of _________.
num ← 5.4
PRINT(num)
num ← 0.0 - ✔✔a void method call
✔✔This part of a method is a collection of statements that are performed when the
method is executed. - ✔✔Method body
✔✔Values that are sent into a method are called ________. - ✔✔actual parameters or
arguments
✔✔When you pass an argument to a method, be sure that the argument's data type is
compatible with: - ✔✔The parameter variable's data type or intended use of the
parameter.
✔✔When code in a method changes data passed by value into its parameter, the
original piece of data is also changed. - ✔✔False
✔✔A parameter variable's scope is: - ✔✔The method in which the parameter is
declared.
✔✔The lifetime of a method's local variable is: - ✔✔Only while the method is executing.
✔✔What will be returned from the following method?
METHOD addTwoNums()
a ← 8.5 + 9.5
return a
END addTwoNums - ✔✔18.0
✔✔This type of method performs a task and then terminates. - ✔✔void
✔✔Which of the following would be a valid method call for the following method?
METHOD showProduct (parameters: num1, num2)
product = num1 * num2
PRINT("The product is " + product)
END showProduct - ✔✔showProduct(10, 4);
✔✔When passing by reference, it is actually a reference to the original place in memory
of the object that is passed. - ✔✔True
, ✔✔The body of a method is demarcated by: - ✔✔{ } or indentation, as dictated by the
language syntax.
✔✔This keyword causes a method to end and sends a value back to the statement that
called the method. - ✔✔return
✔✔A function header is a complete statement and should be terminated according to
the rules of the language you are using. - ✔✔False
✔✔Arguments passed to a method MUST be passed in the same order that the
parameters are defined in the method header. - ✔✔True
✔✔All methods must be called from the main method. - ✔✔False
✔✔This is a control structure that causes a statement or group of statements to repeat.
- ✔✔Loop
✔✔If a loop does not contain within itself a way to terminate, it is called a(n): -
✔✔Infinite loop.
✔✔Each repetition of a loop is known as what? - ✔✔An iteration
✔✔What will be the value of x after the following code is executed?
x←0
WHILE ( x < 5 )
x←x+1
ENDWHILE - ✔✔5
✔✔In the following code, what values could be read into number to terminate the while
loop?
PRINT "Type in a number"READ input
number ← user input
WHILE ( number > 0 )
PRINT "No, that is not it. Try again."
READ input
number ← user input
ENDWHILE - ✔✔Numbers less than or equal to zero
✔✔What will be the value of x after the following code is executed?
x←1
WHILE (x < 0)
x←x+1
SOLUTIONS RATED A+
✔✔In the following code, PRINT(num) is an example of _________.
num ← 5.4
PRINT(num)
num ← 0.0 - ✔✔a void method call
✔✔This part of a method is a collection of statements that are performed when the
method is executed. - ✔✔Method body
✔✔Values that are sent into a method are called ________. - ✔✔actual parameters or
arguments
✔✔When you pass an argument to a method, be sure that the argument's data type is
compatible with: - ✔✔The parameter variable's data type or intended use of the
parameter.
✔✔When code in a method changes data passed by value into its parameter, the
original piece of data is also changed. - ✔✔False
✔✔A parameter variable's scope is: - ✔✔The method in which the parameter is
declared.
✔✔The lifetime of a method's local variable is: - ✔✔Only while the method is executing.
✔✔What will be returned from the following method?
METHOD addTwoNums()
a ← 8.5 + 9.5
return a
END addTwoNums - ✔✔18.0
✔✔This type of method performs a task and then terminates. - ✔✔void
✔✔Which of the following would be a valid method call for the following method?
METHOD showProduct (parameters: num1, num2)
product = num1 * num2
PRINT("The product is " + product)
END showProduct - ✔✔showProduct(10, 4);
✔✔When passing by reference, it is actually a reference to the original place in memory
of the object that is passed. - ✔✔True
, ✔✔The body of a method is demarcated by: - ✔✔{ } or indentation, as dictated by the
language syntax.
✔✔This keyword causes a method to end and sends a value back to the statement that
called the method. - ✔✔return
✔✔A function header is a complete statement and should be terminated according to
the rules of the language you are using. - ✔✔False
✔✔Arguments passed to a method MUST be passed in the same order that the
parameters are defined in the method header. - ✔✔True
✔✔All methods must be called from the main method. - ✔✔False
✔✔This is a control structure that causes a statement or group of statements to repeat.
- ✔✔Loop
✔✔If a loop does not contain within itself a way to terminate, it is called a(n): -
✔✔Infinite loop.
✔✔Each repetition of a loop is known as what? - ✔✔An iteration
✔✔What will be the value of x after the following code is executed?
x←0
WHILE ( x < 5 )
x←x+1
ENDWHILE - ✔✔5
✔✔In the following code, what values could be read into number to terminate the while
loop?
PRINT "Type in a number"READ input
number ← user input
WHILE ( number > 0 )
PRINT "No, that is not it. Try again."
READ input
number ← user input
ENDWHILE - ✔✔Numbers less than or equal to zero
✔✔What will be the value of x after the following code is executed?
x←1
WHILE (x < 0)
x←x+1