1. The term overloaded refers to _________________________. two or more methods
ID: 645005 • Letter: 1
Question
1. The term overloaded refers to _________________________.
two or more methods in different classes that have the same name
2. Java will automatically define a constructor ____________________________.
for every class defined in a program
3. What will happen if a program uses an array index that is out of bounds?
The program will compile and run with no error messages but might give incorrect results.
4. Which of the following is correct Java code?
int[] list = new int[10];
5.
The expression super.puzzle() in a method is a _________________________.
syntax error
6.
An abstract class is a class which _________________________.
has only overridden methods
7.
Which statement best describes overriding a method? Methods in a base class and derived class have the same name _______________________________,
but different number or types of parameters
8.
You need to access values in the order in which they were added (first in, first out), and not randomly. Which collection type should you use?
Queue
9.
A programmer-defined exception class _________________________.
should contain at least one int variable to store the exception code number
10.
The parameter to the Exception class constructor _________________________.
is a boolean telling whether or not the program should terminate
11.
Which of the following statements about hash functions is NOT correct?
If you supply your own hashCode method for a class, it must be compatible with that class's equals method.
12.
Where is the easiest place to add new nodes to a linked list?
Wherever there is an empty position.
13.
Complete the following code, which is intended to print out all key/value pairs in a map named myMap that contains String data for student IDs and names:
Map myMap = new HashMap();
. . .
_______________________________
for (String aKey : mapKeySet)
{
String name = myMap.get(aKey);
System.out.println("ID: " + aKey + "->" + name);
}
Set mapKeySet = myMap.keySet();
14.
What will be the value returned by the method anotherMystery below if called with the parameter 3?
public static int anotherMystery(int n)
{
if (n < 1)
return 1;
else
return 2 + anotherMystery(n + 1);
}
No value will be returned because the recursion will not terminate.
15.
Recursion should be used _________________________.
when there is no non-recursive alternative
16.
A program can tell which button was clicked by using the _________________________.
second parameter of the ActionPerformed method
17.
Which of the following statements about the TreeSet class is NOT correct?
To use a TreeSet, it must be possible to compare the elements.
18.
Binary search can be used and is faster than the linear search, providing the _________________________.
element being searched for is actually in the array
19.
What is the output of the following statements?
ArrayList names = new ArrayList();
names.add("Bob");
names.add(0, "Ann");
names.remove(1);
names.add("Cal");
names.set(1, "Tony");
for (String s : names)
{
System.out.print(s + ", ");
}
Cal, Bob, Tony
20.
Why is it generally considered good practice to minimize coupling between classes?
Low coupling decreases the probability of code redundancy.
I have 50 minutes to finish it. Please answer correctly. Thanks
an error where more than one method matches a method callExplanation / Answer
Answer
1.two or more methods in the same class that have the same name
2.if the programmer does not define a default constructor for a class
3.
The program will compile and run with no error messages but might give incorrect results.
4. int list[10];
5.call to the puzzle method in the base class
6.has only overridden methods
7.
but have different return types
8
Hashtable
9.should not have more than one instance variable
10.tells the statement where execution should resume
11.A hash function produces a unique integer-valued hash code value for each distinct object.
12.
Wherever there is an empty position.
13. Map mapKeySet = myMap.keySet();
14.9
15.when efficiency and performance are important
16. getActionCommand method in the event object
17.
Elements are arranged in linear fashion.
18.
element being searched for is actually in the array
19.Cal, Bob, Tony
20.High coupling increases program maintenance and hinders code reuse
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.