Shared Flashcard Set

Details

Exam 2 Questions
Continuation
45
Computer Science
Undergraduate 2
04/27/2013

Additional Computer Science Flashcards

 


 

Cards

Term
True/False: In a two-dimensional array, all of the rows must have the same number of elements.
Definition
False
Term
The term overloaded refers to
Definition
two or more methods in the same class that have the same name
Term
True/False: An accessor method that returns an array should return a copy of an instance variable array rather than the instance variable itself.
Definition
True
Term
A private instance variable
Definition
can be modified by a method outside the class if it is a class type, using a mutator method (assuming one exits)
Term
An _____ method is one which has no body and is meant to be overridden in every derived class.
Definition
abstract
Term
Adding the _____ modifier to a method heading prevents derived classes from overriding the method.
Definition
final
Term
True/False: It is possible to have two methods in the same class that have the same name, the same number and types of arguments, but different return types.
Definition
False
Term
An abstract class
Definition
is a class which cannot be instantiated
Term
What determines whether a method definition in a derived class or an ancestor class will be used?
Definition
the object's place in the inheritance chain
Term
What does the acronym API stand for
Definition
Application Programming Interface
Term
Every array object has an instance variable called _____ that tells how many elements are in the array
Definition
length
Term
The behavior of an object is defined by its
Definition
public methods
Term
The relationship between a class and an object is best described as
Definition
objects are instances of classes
Term
In a class, the modifier _____ identifies data and operations that can be used only by methods in the class.
Definition
private
Term
True/False: The index to use with an array can be an expression whose value is computed when the program runs.
Definition
True
Term
True/False: If one element from an array is passed as a parameter to a method, then the called method can modify any element in the array.
Definition
False
Term
In the description of a method, a ______ specifies a necessary condition that must apply in order that the operation can execute successfully
Definition
precondition
Term
True/False: Every array has a method called equals that can be used to compare it to other arrays.
Definition
False
Term
True/False: When implementing a class method, a programmer typically chooses to throw an exception when the method violates a postcondition.
Definition
False
Term
True/False: An accessor method that returns an array should return a copy of an instance variable array rather than the instance variable itself.
Definition
True
Term
Which Java package is automatically imported by any application?
Definition
java.lang
Term
True/False: The size of an array in Java is determined when the program is compiled.
Definition
False
Term
True/False: You can change the size of an array by assigning a new value to the length instance variable.
Definition
False
Term
True/False: The first element in an array is accessed using zero as an index.
Definition
True
Term
True/False: Arrays in Java are objects
Definition
True
Term
True/False: Selection sort is not one of the easier to understand sorting algorithms, but it is one of the most efficient.
Definition
False
Term
Selection sort works by repeatedly
Definition
finding the smallest element in the remainder of the list and moving it forward
Term
Usually the _____ node is the only node in the list for which there is a named variable.
Definition
head
Term
An _____ is an object that allows you to step through a list and perform some action for each element of the list.
Definition
Iterator
Term
To make a linked list that can contain different kinds of elements, the data instance variable should be defined as ______
Definition
generic
Term
Each node in a linked list has some data and a(n)______ to another node
Definition
reference
Term
Links in a linked list are usually
Definition
references
Term
What happens to nodes that are deleted from a linked list?
Definition
The memory they used is reclaimed for other uses automatically.
Term
Where is the easiest place to add new nodes to a linked list?
Definition
At the beginning of the list.
Term
Extend the declaration of the Circle class so that it implements the Comparable interface. The class header is
Definition
public class Circle implements Comparable
Term
LinkedList alist = new LinkedList(); alist.add("red"); alist.add("tan"); What is stored in alist at index 1?
Definition
tan
Term
LinkedList alist = new LinkedList(); alist.add("red"); alist.add("tan"); alist.add(1, "green"); alist.add(2, "blue"); What is stored in alist at index 1?
Definition
green
Term
LinkedList alist = new LinkedList(); alist.add("red"); alist.add("tan"); alist.add(1, "green"); alist.add(2, "blue"); alist.remove(alist.size()-1); alist.remove(1); What is stored in alist at index 1?
Definition
blue
Term
In an inheritance hierarchy, you cannot instantiate an object when its type is:
Definition
an abstract class
Term
In an inheritance hierarchy, you can instantiate an object when the type is
Definition
a superclass with only private instance variables
Term
Which of the following is not a characteristics of static arrays:
Definition
The size of the block that is allocated is fixed, but it is possible to allocate a new block of memory.
Term
Which of the following is not a characteristic of a dynamic array:
Definition
The memory allocated for the array is permanently bound to the array variable name.
Term
Which of the following is not a basic array operation?
Definition
Changing an element's class type
Term
Each array stores the number of cells that are allocated to the array in a field that is part of the data structure. This is the upper bound on the number of elements that can be stored in the array and represents the capacity of the array. What is the name of this field?
Definition
length
Term
Which of the following is not an important characteristics of linked data structures that distinguish them from arrays?
Definition
Nodes can hold any type of data.
Supporting users have an ad free experience!