NEW
Font size
WorksheetsFunctions and Parameters Summative preview
Total questions: 10
Worksheet time: 6mins
What is the output of the following program?
5
15
15
5
nothing will print
5
What is printed by the following program?
-7
7
=13
13
What will be printed to the screen when the following program is run?
function start(){
println(doubleNumber(doubleNumber(10)));
}
function doubleNumber(x){
var doubledX = 2 * x;
return doubledX;
}
20
100
40
x
In the following function printThreeTimes:
function printThreeTimes(word){
println(word);
println(word);
println(word);
}
What is the parameter of the function?
word
word
word
word
no parameter
println
What is the minimum number of parameters that must be given when calling the ‘drawCircle’ function?
function drawCircle(radius, x, y, color) {
var circle = new Circle(radius);
circle.setPosition(x, y);
circle.setColor(color);
add(circle);
}
1
2
0
4
// This function prints out the area of a rectangle given its base and height function rectangleArea(base, height){
var area = base * height;
println(area);
}
What are the names of the parameters?
base and height
length and width
var area
println(area)
What is printed by the program?
2
1
0
two
one
zero
nothing will print
0
1
2
is var RADIUS = 35
in the program shown
a LOCAL or GLOBAL variable?
LOCAL
GLOBAL
it isn't a variable
If it’s not a bird and it’s not a plane, it must be Superman.
Will the following function work to find Superman?
function isSuperman(isBird, isPlane){
return !isBird && !isPlane;
}
Yes it will work
No it won't work
How many parameters go into the function sum, and how many return values come out of the function sum
function sum(first, second, third){
var result = first + second + third;
println(first);
println(second);
println(third);
return result;
}
3 parameters go in,
1 return value comes out
3 parameters go in,
3 return value comes out
No parameters go in
No result comes out
