Font size
WorksheetsParameters vs Constants
Total questions: 10
Worksheet time: 6mins
Which is false about parameters?
Parameters allow a function to perform tasks without knowing the specific input values ahead of time.
If you were to use different values within a single execution, you will use a parameter.
A parameter cannot change it value during a package execution.
There are 3 types of parameters.
Are parameters and constants the same?
True
False
Which of the following is are types of parameters
Flow
Boolean
Array
Syntax Error
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");
}
( string, Fname)
(String)
(fname, fname)
(String)
( String, fname)
(fname)
(String, string)
(Fname)
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));
}
String args
public static void
println
return
What 2 things do constants do in java?
Helps make a program easier
Simplifies an algorithm
Helps define for loop in a nested loop
Helps define a constant data within a class
What is the basic rule of a constant?
(a)
How many types of constants are determined?
1
2
3
4
A constant is a variable whose value cannot change once it is assigned?
True
False
To turn an ordinary variable into a constant, you have to use the keyword "final."?
False
True
