wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Parameters vs Constants

Total questions: 10

Worksheet time: 6mins

Name
Class
Date
1.

Which is false about parameters?

a)

Parameters allow a function to perform tasks without knowing the specific input values ahead of time. ​

b)

If you were to use different values within a single execution, you will use a parameter.

c)

A parameter cannot change it value during a package execution.​ ​

d)

There are 3 types of parameters.

2.

Are parameters and constants the same?

a)

True

b)

False

3.

Which of the following is are types of parameters

a)

Flow

b)

Boolean

c)

Array

d)

Syntax Error

4.

Add a fname parameter of type String to myMethod, and output "John Doe".


static void myMethod( , ) {

System.out.println( + " Doe");

}


public static void main(String[] args) {

myMethod("John");

}

a)

( string, Fname)

(String)

b)

(fname, fname)

(String)

c)

( String, fname)

(fname)

d)

(String, string)

(Fname)

5.

Insert the missing part to print the number 8 in main, by using a specific keyword inside myMethod:


static int myMethod(int x) {

5 + x;

}


public static void main(String[] args) {

System.out.println(myMethod(3));

}

a)

String args

b)

public static void

c)

println

d)

return

6.

What 2 things do constants do in java?

a)

Helps make a program easier

b)

Simplifies an algorithm

c)

Helps define for loop in a nested loop

d)

Helps define a constant data within a class

7.

What is the basic rule of a constant?

(a)  

8.

How many types of constants are determined?

a)

1

b)

2

c)

3

d)

4

9.

A constant is a variable whose value cannot change once it is assigned?

a)

True

b)

False

10.

To turn an ordinary variable into a constant, you have to use the keyword "final."?

a)

False

b)

True