AND SOLUTIONS RATED A+
✔✔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
ENDWHILE - ✔✔1
✔✔What will be the value of x after the following code is executed?
x←5
WHILE (x >= 0)
x ← x -1
ENDWHILE - ✔✔-1
✔✔This type of loop should be used when you want your loop to iterate at least once. -
✔✔do while
✔✔What will be the value of x after the following code is executed?
x ← 10
FOR(y ← 5, y < 20, y ← y + 5)
x←x+y
ENDFOR - ✔✔40
✔✔What will be printed after the following code is executed?
FOR(number ← 5, number <= 15, number ← number + 3)
PRINT number + ", "
ENDFOR - ✔✔5, 8, 11, 14,
✔✔This type of loop is ideal in situations where the exact number of iterations is known.
- ✔✔for loop