Assuming the statement below is valid, and assuming a method named fred() exists in both Class1 and Class 2, which of the following is true?
Class1 c = new Class2(1000);
Assuming the statement below is valid, and assuming a method named fred() exists in both Class1 and Class 2, which of the following is true?
Class1 c = new Class2(1000);
Front
c.fred() will result in a call to the method in Class1
"c.fred() will result in a call to the method in Class2"
c.fred() will result in an error
Back
This search algorithm steps sequentially through an array, comparing each item with the search value
Front
sequential search
Back
Given the following class header, which class constructor will execute first?
public class Robin extends Bird
Front
Bird
Back
Write a method header for a public method named calculateMean that takes a String argument named filename, and that returns a double, and may generate a FileNotFoundException
Front
public double calculateMean(String filename) throws FileNotFoundException {
}
Back
This is one of the methods that is common to both the String and StringBuilder classes
Front
length
Back
These static final variables are members of the numeric wrapper classes and hold the minimum and maximum values for a particular data type
Front
MIN_VALUE & MAX_VALUE
Back
When a class implements an interface, it must
Front
provide all of the methods that are listed in the interface, with the exact signatures and return types
Back
The indexOf and lastIndexOf methods can find characters, but cannot find subStrings.
Front
False
Back
In Java, the first (head) element of a list has
Front
index 0
Back
This key word refers to an object's superclass
Front
super
Back
This is an internal list of all the methods that are currently executing
Front
call stack
Back
You can think of this code as being "protected" because the application will not halt if it throws an exception.
Front
try block
Back
An iterator's remove method can be called more than once between calls to next.
Front
False
Back
In which of the big O notation complexity classes is the sequential search?
Front
O(n) linear time. An increase in input size results in a proportionally large increase in running time.
Back
The startsWith and endsWith method are case-sensitive.
Front
True
Back
Abstract methods must be
Front
overriden
Back
The number of elements actually stored in a list.
Front
size
Back
A list's capacity is less than its size
Front
False
Back
Character testing methods, such as isLetter, accept strings as arguments and test each character of the string.
Front
False
Back
In the __________ algorithm, the smallest value in the array is located and moved to element 0. Then the next smallest value is located and moved to element 1. The process continues until all of the elements have been placed in their proper order
Front
selection sort
Back
Under what conditions should you use StringBuilder objects instead of String objects?
Front
When you want to change the contents of a string without creating a new object
Back
This method converts a character to uppercase.
Front
toUpperCase
Back
If your code does not handle an exception when it is thrown, it is dealt with by this.
Front
default exception handler
Back
This search algorithm is adequate for small arrays but not for large arrays
Front
sequential search
Back
This search algorithm requires that the array's contents be sorted.
Front
binary search
Back
To handle an exception gracefully, you
Front
catch it
Back
This String class method performs the same operation as the + operator when used on Strings.
Front
concat
Back
To add an element e to a linked list, just after a node referenced by ref, you should use the statement:
Front
ref.next = new Node(e, ref.next);
Back
A class can implement only one interface.
Front
False
Back
All exception classes inherit from this class.
Front
Throwable
Back
In which of the big O notation complexity classes does finding the largest value in an unsorted array belong?
Front
O(n) linear time. An increase in input size results in a proportionally large increase in running time.
Back
The indexOf and lastIndexOf methods are members of this class.
Front
String
Back
The recursive RLinkedList class contains all the methods required by the List interface.
Front
False
Back
In which of the big O notation complexity classes is the binary search?
Front
O(log n) logarithmic time. A large increase in input size results in a small increase in running time.
Back
If a subclass constructor does not explicitly call a superclass constructor, Java will call the no-arg superclass constructor.
Front
True
Back
This search algorithm repeatedly divides the portion of an array being searched in half.
Front
binary search
Back
The startsWith, endsWith and regionMatches methods are members of this class.
Front
String
Back
A method in a subclass having the same signature as a method in the superclass is an example of
Front
overriding
Back
To conveniently remove a node that is not the head of a singly-linked list, you need a reference to
Front
the predecessor node
Back
This method can be used to retrieve the error message from an exception object.
Front
getMessage
Back
Each element in a list except the last element has a(n)
Front
successor
Back
The numeric wrapper classes' "parse" methods all throw an exception of this type.
Front
NumberFormatException
Back
If you have an ArrayList<String> named tb that looks like this when printed:
[John, Paul, George, Ringo]
Who gets removed by the following?
Iterator<String> it = tb.iterator();
it.next();
it.next();
it.remove();
Front
Paul
Back
A subclass in a different package from its superclass can access the superclass's fields if they are
Front
protected or public
Back
This is a section of code that gracefully responds to exceptions.
Front
exception handler
Back
When an exception is generated, it is said to have been ____________
Front
thrown
Back
In which of the big O notation complexity classes is the worst case of all 4 sort algorithms we studied?
Front
O(n2) quadratic time, the simplest case of polynomial time. An increase in input size results in a much greater increase in running time.
Back
In which of the big O notation complexity classes does finding the largest value in a sorted array belong?
Front
O(1) constant time (i.e. the time to run the algorithm is constant, not dependent on input size)
Back
Consider the following class header. Which of the following statements is true?
Front
an object of type SubClass inherits a toString method, whether there is one in SuperClass or not
SuperClass is the base class
SuperClass could be an abstract class.
"all of these are true"
Back
Given the following declaration and current contents ["John", "George", "Ringo"], which of the answers uses a standard List method to delete "George"?
List<String> theBeatles = new ArrayList<String>();
A) theBeatles.remove("George");
B) theBeatles.remove(1);
Front
A and B
Back
Section 2
(10 cards)
The isDigit, isLetter, and isLetterOrDigit methods are members of this class
Front
Character
Back
Which of the following can be instantiated? (Which of the following can be used to create an object without subclassing?)
A) an interface
B) a class with an abstract method
C) an abstract class
Front
None
Back
If you do not provide an access specifier, which of the following is the default?
Front
package
Back
Write a public method named fred that calls a superclass method also named fred. Both methods accept and return ints. The method you write should pass its parameter to the superclass method and return twice the return value from the superclass method.
Front
public int fred (int n)
{
return 2 * super.fred(n);
}
Back
A method in a subclass having the same name as a method in the superclass but a different signature is an example of
Front
overloading
Back
Abstract classes cannot
Front
be instantiated
Back
Write the class header for class A. Class A should implement the Serializable interface. (Write just one line)
Front
public class A implements Serializable {
}
Back
All classes directly or indirectly inherit from this class.
Front
Object
Back
The String class has several overloaded versions of a method that accepts a value of any primitive data type as its argument and returns a String representation of the value. The name of the method is:
Front
valueOf
Back
In the method header below, which of the following is true?
public class CheckingAccount extends BankAccount
A) CheckingAccount is the superclass
B) BankAcount is the superclass
C) An object of type BankAccount can be used to call all of the (public) methods of the CheckingAccount Class.