WorksheetsGrade11_COMPROG2_Q4_Quiz#2
Total questions: 15
Worksheet time: 10mins
What is a function in programming?
A large program that does multiple tasks.
A self-contained block of code that performs a specific task.
A variable used to store values.
A random set of statements with no clear purpose.
In Java, functions are called:
procedures
methods
subroutines
commands
Which of the following is NOT a characteristic of functions?
Reusability
Encapsulation
Modularity
Random Execution
What is the main advantage of using methods in Java?
Makes the code more complex.
Reduces code reusability.
Organizes and simplifies code.
Increases redundancy.
What is a built-in method in Java?
A method defined by the user.
A method provided by Java form common tasks.
A method that requires a return type.
A method that does not accept parameters.
Which of the following is an example of a built-in method in Java?
userDefinedMethod()
Math.sqrt(25)
myFunction()
computeSomething()
How do you call a method in Java?
By defining it inside main().
By using its name followed by parentheses.
By writing its return type only.
By declaring it without paremeters.
What does a method return type specify?
The number of parameters the method takes.
The type of value the method will return.
The number of times the method runs.
The number of statements inside the method.
What keyword is used when a method does not return a value?
static
void
return
final
What is method overloading?
Using multiple return types in a single method.
Creating multiple methods with the same name but different parameters.
Running a method multiple times in a loop.
Defining methods with identical paremeters.
Which of the following is true about method scope?
Local variables can access outside the method.
Global variables can be used anywhere within the class.
Methods cannot have parameters.
Static methods require object creation to be used.
What does the static keyword indicate in a method?
The method belongs to an instance of a class.
The method can be accessed without creating an object.
The method requires parameters.
The method must return a value.
All methods in Java must return a value.
TRUE
FALSE
Method overloading helps in improving code readability and reusability.
TRUE
FALSE
A static method can be called without creating an instance of the class.
TRUE
FALSE
