wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Functions and Parameters Summative preview

Total questions: 10

Worksheet time: 6mins

Name
Class
Date
1.

What is the output of the following program?

a)

5

15

b)

15

5

c)

nothing will print

d)

5

2.

What is printed by the following program?

a)

-7

b)

7

c)

=13

d)

13

3.

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;

}

a)

20

b)

100

c)

40

d)

x

4.

In the following function printThreeTimes:

function printThreeTimes(word){

println(word);

println(word);

println(word);

}

What is the parameter of the function?

a)

word

word

word

b)

word

c)

no parameter

d)

println

5.

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);

}

a)

1

b)

2

c)

0

d)

4

6.

// 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?

a)

base and height

b)

length and width

c)

var area

d)

println(area)

7.

What is printed by the program?

a)

2

1

0

b)

two

one

zero

c)

nothing will print

d)

0

1

2

8.

is var RADIUS = 35

in the program shown

a LOCAL or GLOBAL variable?

a)

LOCAL

b)

GLOBAL

c)

it isn't a variable

9.

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;

}

a)

Yes it will work

b)

No it won't work

10.

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;

}

a)

3 parameters go in,

1 return value comes out

b)

3 parameters go in,

3 return value comes out

c)

No parameters go in

d)

No result comes out