CSC Exam 2
This is the typical number of comparisons performed by the sequential search on an array of N elements ( assuming the search values are consistently found).
N/ 2
All classes directly or indirectly inherit from this class.
Object
Assuming the following declaration exists: enum Seasons { SPRING, WINTER, SUMMER, FALL } what is the fully qualified name of the FALL constant?
Seasons. FALL
You cannot use the fully qualified name of an enum constant for this.
a case expression
When an object is passed as an argument to a method, this is actually passed.
a reference to the object
This is a method that gets a value from a class's field, but does not change it.
accessor
To insert an item at a specific location in an ArrayList object, you use this method. a. store b. insert c. d. get
add
Making an instance of one class a field in another class is called ___________.
aggregation
In a subclass constructor, a call to the superclass constructor must __________ .
appear as the very first statement
Abstract classes cannot __________ .
be instantiated
This search algorithm repeatedly divides the portion of an array being searched in half.
binary search
The process of matching a method call with the correct method is known as __________.
binding
A class is analogous to a( n) __________.
blueprint
Fields in an interface are __________ .
both final and static
When initializing a two- dimensional array, you enclose each row's initialization list in ___________. a. b. parentheses c. brackets d. quotation marks
braces
This is a collection of programming statements that specify the fields and methods that a particular type of object may have.
class
This is a method that is automatically called when an instance of a class is created.
constructor
This is automatically provided for a class if you do not write one yourself.
default constructor
With this type of binding, the Java Virtual Machine determines at runtime which method to call, depending on the type of the object that a variable references.
dynamic
This key word indicates that a class inherits from another class.
extends
This is a class member that holds data.
field
If a class has this method, it is called automatically just before an instance of the class is destroyed by the Java Virtual Machine.
finalize
The Java Virtual Machine periodically performs this process, which automatically removes unreferenced objects from memory.
garbage collection
An object is a( n) __________.
instance of a class
This operator can be used to determine whether a reference variable references an object of a particular class.
instanceof
This array field holds the number of elements that the array has.
length
This is a method that stores a value in a field or in some other way changes the value of a field.
mutator
This key word causes an object to be created in memory.
new
This enum method returns the position of an enum constant in the declaration.
ordinal
A method in a subclass having the same name as a method in the superclass but a dif-ferent signature is an example of __________ .
overloading
Abstract methods must be __________ .
overridden
A method in a subclass that has the same signature as a method in the superclass is an example of __________ .
overriding
A subclass does not have access to these superclass members.
private
These superclass members are accessible to subclasses and classes in the same pack-age.
protected
When a class implements an interface, it must __________ .
provide all of the methods that are listed in the interface, with the exact signatures and return types specified
To delete an item from an ArrayList object, you use this method. a. b. delete c. erase d. get
remove
This search algorithm steps through an array, comparing each item with the search value.
sequential search
When a local variable has the same name as a field, the local variable's name does this to the field's name.
shadows
To determine the number of items stored in an ArrayList object, you use this method. a. b. capacity c. items d. length
size
In an array declaration, this indicates the number of elements that the array will have.
size declarator
When the value of an item is dependent on other data, and that item is not updated when the other data is changed, what has the value become?
stale
This type of method cannot access any non- static member variables in its own class.
static
In an inheritance relationship, this is the specialized class.
subclass
Each element of an array is accessed by a number known as a( n) __________.
subscript
This key word refers to an object's superclass.
super
The following is an explicit call to the superclass's default constructor.
super();
In an inheritance relationship, this is the general class.
superclass
Two or more methods in a class may have the same name, as long as this is different.
their parameter lists
A class's responsibilities are __________.
things the class knows. actions the class performs
This is the name of a reference variable that is always available to an instance method and refers to the object that is calling the method.
this
If you write this method for a class, Java will automatically call it any time you con-catenate an object of the class with a string.
toString
Enumerated data types are actually special types of classes.
true
You can declare an enumerated data type inside a method.
true
enum constants have a toString method.
true
Array bounds checking happens __________.
when the program runs
The first subscript in an array is always ___________.
0
The last subscript in an array is always __________.
1 less than the number of elements
CRC stands for
Class, Responsibilities, Collaborations
A class may not have more than one constructor.
False
A class may only implement one interface.
False
A method cannot return a reference to an object.
False
A static member method may refer to non- static member variables of the same class, but only after an instance of the class has been defined.
False
A subclass reference variable can reference an object of the superclass.
False
A superclass has a member with package access. A class that is outside the superclass's package but inherits from the superclass can access the member.
False
All static member variables are initialized to - 1 by default.
False
An array's sitze declarator can be a negative integer expression.
False
An object of a superclass can access members declared in a subclass.
False
If a subclass constructor does not explicitly call a superclass constructor, Java will not call any of the superclass's constructors.
False
The first size declarator in the declaration of a two- dimensional array represents the number of columns. The second size declarator represents the number of rows.
False
To find the classes needed for an object- oriented application, you identify all of the verbs in a description of the problem domain.
False
When a method is declared with the final modifier, it must be overridden in a subclass.
False
When you write a constructor for a class, it still has the default constructor that Java automatically provides.
False
A superclass reference variable can reference an object of a subclass that extends the superclass.
True
A two- dimensional array has multiple length fields.
True
An ArrayList automatically expands in size to accommodate the items stored in it.
True
Both of the following declarations are legal and equivalent: int[] numbers; int numbers[];
True
By default all members of an interface are public.
True
Constructors are not inherited.
True
Each instance of a class has its own set of instance fields.
True
In a subclass, a call to the superclass constructor can only be written in the subclass constructor.
True
Java does not allow a statement to use a subscript that is outside the range of valid subscripts for an array.
True
The Java compiler does not display an error message when it processes a statement that uses an invalid subscript.
True
The new operator creates an instance of a class.
True
The subscript of the last element in a single- dimensional array is one less than the total number of elements in the array.
True
The superclass constructor always executes before the subclass constructor.
True
The values in an initialization list are stored in the array in the order that they appear in the list.
True
When a class contains an abstract method, the class cannot be instantiated.
True
When an array is passed to a method, the method has access to the original array.
True
When an object is passed as an argument to a method, the method can access the argument.
True