1. The following code shows the syntax of a method. What is 'public static'?
2. In the code above, 'int' is the:
3. In the code in question 1, 'a,b' are:
4. In the code in question 1, 'int a, int b' are:
5. What is the output of the following code? Minimum Value =
6. A parameter is a _____ that you can pass to a method in Java.
7. Passing Parameters by _____ means calling a method with a parameter. Through this, the argument value is passed to the parameter.
8. The following example shows an example of passing parameter by ______.
9. When a class has two or more methods by the same name but different parameters, it is known as method ___________.
10. In ____________, a method has the same method name, type, number of parameters, etc
11. _________ are constructed out of statements which are placed between brackets like these "{ }" as shown below:
package exlcode;
public class MethodExample {
public static int exampleVariableOne = 5;
public static int exampleVariableTwo = 10;
public static void main(String[] args) {
// this prints the sum of exampleVariableOne and exampleVariableTwo
System.out.println(add(exampleVariableOne, exampleVariableTwo));
}
// this method takes in two parameters and
// returns the sum of the two parameters
public static int add(int parameterOne, int parameterTwo) {
return parameterOne + parameterTwo;
}
}
12. In the above example, the return type _____ signifies that the method does not return anything, which is why we do not see a statement that says return.
13. Analyse the following code. Is the following statement true or false? Changing the value of parameterOne does affect the value of exampleVariableOne.
14. When dealing with methods, when we need more than one parameter, they are written one after the other, separated by a semi colon.
15. All parameters are just copies of the original value or address. Regardless of what we do to the parameter inside the method, the original value ?....
16. _____' is a keyword in Java which is used as a reference to the object of the current class, with in an instance method or a constructor.
17. A method that accepts parameters must list the parameters in the method declaration. The parameters are placed in a parameter list inside the parentheses that follow the method name.
18. For each parameter used by the method, you list the parameter _____ followed by the parameter name.
19. The names you use for parameters can be the same as the names you use for the variables you pass to the method when you call it, but they don?t have to be.
20. When Java passes a variable to a method via a parameter, the method itself receives a copy of the variable?s value, not the variable itself.
21. Analyse the following code. Which of the following statements is correct?
22. Refer to the code above. Even though the tryToChangeNumber method changes the value of its parameter, that change has no effect on the original variable that was passed to the method.
23. Bill has a class which defines two overloaded methods. The first function is a function of a single argument (which must be provided) and can only validly ________________________.
24. Referring to the code in the previous question, the second function doesn't take an argument and _______________________.
25. The Void class is an uninstantiable placeholder class to hold a reference to the Class object representing the Java keyword void.
26. Because the Void class can not be instantiated, the only value you can pass to a method with a Void type parameter, such as handle(Void e), is ____.
27. If you are declaring a method, you state parameters with classes, such as:
28. What is the output of the following code?
29. What is the process of defining two or more methods within same class that have same name but different parameters declaration?
30. What is the output of the following code?