Answers need to be true or false 1. Declaring more than one method with the same
ID: 3836427 • Letter: A
Question
Answers need to be true or false
1. Declaring more than one method with the same name but different sets of parameters is called method overloading.
2. You cannot overload a constructor.
3. Given a method with the signature:
public void numberCruncher(int num1, int num2, String name)
an example call to this method could be:
myNumberCrunch.numberCruncher("Fred", 3, 5)
4. The + operator can be used in string concatenation.
5. A static method can be used even if no objects of the class have been instantiated.
6. A class or static variable should be used when all objects of a class must use the same copy of the variable.
7. If packages are used, the package declaration should come directly after any import declarations in a java source file.
8. The private access modifier can control the access to variables and methods of a class.
9. An accessor is another term for a set method.
10. Arrays have to hold the values of the same type.
11. The first index of an array is index zero.
12. The following code creates an array, b, with 3 columns and 2 rows:
int[][] b = new int[2][3];
13. Given an array called x, you can access the 5th element in array x by the following code:
x[5]; //reference the 5th element in an array
14. Nested for loops are commonly used to display the contents of 2-dimensional arrays.
15. The enhanced "for" statement will iterate through the elements of an array.
16. Given array ‘y’ that holds values of type int, the following code will set the 5th element of the array to 6:
Y[6] = 5;
17. A list of method parameters are separated by semicolons.
18. A method can return at most one value.
19. Class Math has several static methods.
20. The Java Application Programming Interface is a Java class library with thousands of predefined classes.
Explanation / Answer
1. Declaring more than one method with the same name but different sets of parameters is called method overloading. : True
2. You cannot overload a constructor. : False
3. Given a method with the signature:
public void numberCruncher(int num1, int num2, String name)
an example call to this method could be:
myNumberCrunch.numberCruncher("Fred", 3, 5) : False
Correct Solution will be myNumberCrunch.numberCruncher( 3, 5,"Fred")
4. The + operator can be used in string concatenation. : True
5. A static method can be used even if no objects of the class have been instantiated. : True
6. A class or static variable should be used when all objects of a class must use the same copy of the variable.: True
7. If packages are used, the package declaration should come directly after any import declarations in a java source file. : False (package comes before imports)
8. The private access modifier can control the access to variables and methods of a class. : True
9. An accessor is another term for a set method. : False, Accessor is for get Methods, Mutators are for set methods
10. Arrays have to hold the values of the same type. : True , they hold homogenous data
11. The first index of an array is index zero.: True, index starts from 0
12. The following code creates an array, b, with 3 columns and 2 rows:
int[][] b = new int[2][3]; : True, 2 rows and 3 cols
13. Given an array called x, you can access the 5th element in array x by the following code:
x[5]; //reference the 5th element in an array : False, 5th element is accessed using x[4]
14. Nested for loops are commonly used to display the contents of 2-dimensional arrays. : True
15. The enhanced "for" statement will iterate through the elements of an array. : True
16. Given array ‘y’ that holds values of type int, the following code will set the 5th element of the array to 6:
Y[6] = 5; : False, it should be Y[4] = 6
17. A list of method parameters are separated by semicolons. : False, they are seperated by comma
18. A method can return at most one value. : True
19. Class Math has several static methods. : True, like Math.sqrt() , math.max
20. The Java Application Programming Interface is a Java class library with thousands of predefined classes. : True
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.