• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/80

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

80 Cards in this Set

  • Front
  • Back
What is an Object?
An object encapsulates state and behavior.
What is the difference between the “client view” and the “implementer view”?
The external/client view is the "what" part (knowing what the object does) and the internal/implementation view is the "how" part (knowing how the object does it).
What is a “generic class”?
A type in Java that is written to accept another type as part of itself
What method is called in the ArrayList class to dynamically include new items?
add()
In the ArrayList class describe the use of the contains() method.
Returns true if the given element is in the list
Define “Boxing”.
An automatic conversion from primitive data to a wrapped object of the appropriate type (e.g., an int boxed to form an Integer).
Define “Unboxing”.
An automatic conversion from wrapped object to its corresponding primitive data (e.g., an Integer unboxed to form an int).
What is a “Wrapper Class”?
A class that wraps primitive data as an object.
What method is called in the ArrayList class to dynamically eliminate items?
remove()
In the ArrayList class describe the use of the size() method.
Returns the current number of elements in the list.
What is the problem with the following code:
for (String s : words)
{
if (s.equals(“hello”))
{
words.add(“goodbye”);
}
}
It is illegal to modify the elements of an ArrayList while for-eaching over it.
What is the problem with the following code:
ArrayList numbers = new ArrayList();
Primatives cannot be specified as type parameters for generic types.
Define the term “Comparison Function”?
A well-defined procedure for deciding, given a pair or values, the relative order of the two values (less than, equal, or greater than)..
Define the term “Natural Ordering”?
The order imposed on a type by its comparison function.
Which interface is used to implement object comparison?
The Comparable interface.
Define the term “Collection”?
An object that stores a group of objects, called its elements.
What is a List?
An ordered collection of elements accessed by integer indexes.
What is a Stack?
A collection where the last element added is the first one to be removed.
(i.e. LIFO)
What is a Queue?
A collection where elements are removed in the order in which they were added.
(i.e. FIFO)
What is the name of the framework that is largely contained in the package java.util?
The Java Collections Framework.
What is a Linked List?
A collection that stores a list of elements in small object containers called nodes, which are linked together.
What is an Iterator?
An object that allows you to efficiently retrieve the elements of a list in sequential order.
Define the acronym ADT?
Abstract Data Type.
What is a Set?
A collection that stores a group of elements and prevents duplicates.
What is a Map?
A collection that associates objects called keys with objects called values.
What is the purpose of the binarySearch(list, value) method of the Collections Class?
Searches a sorted list for a given element value and returns its index.
What are the strengths/differences between an ArrayList and a LinkedList?
ArrayList – random access; any element can be accessed quickly; adding and removing at the end of the list is fast.
LinkedList – adding and removing at either end of the list is fast; fast add/remove during a sequential access with an iterator; no need to expand an array when full; can be more easily used as a queue.
What is an Abstract Data Type?
A specification of a type of data and the operations that can be performed on it.
What are the strengths/differences between a HashSet and a TreeSet?
HashSet – extremely fast performance for add, contains, and remove; can be used with any type of objects as its elements.
TreeSet – elements are sorted in sorted order; must be used with elements that can be compared (i.e. Integer, String).
Why doesn’t the MAP collection have an iterator method?
Because exactly what you wanted to iterate over wouldn’t be clear.
What are the two major methods implemented to support operations on the Stack collection? Describe what they are designed to accomplish.
Push() – put elements on the stack
Pop() – remove and return elements off of the stack
What are the two major methods implemented to support operations on the Queue collection? Describe what they are designed to accomplish.
Enqueue() – add elements to the back of the queue
Dequeue() – take elements out of the front of the queue
What is Recursion?
A programming technique in which you describe actions to be repeated using a methods that calls itself.
What is a Base Case?
A case that is so simple that it can be solved directly without a recursive call.
What is a Recursive Case?
A case that involves reducing the overall problem to a simpler problem of the same kind that can be solved by a recursive call.
Define the term “fractal”.
A mathematically generated, self-similar image.
Who created the “fractal”?
Created by B. Mandelbrot in 1975
Why do we care about “fractals” in this course?
Many can be drawn elegantly using recursive algorithms
What is the problem with a recursive solution to the Fibonacci numbers problem?
fibonacci(n) recomputed fibonacci(n-1 ... 1) many times in finding its answer!
this is a common case of "overlapping subproblems" or "divide poorly and reconquer", where the subtasks handled by the recursion are redundant with each other and get recomputed
What causes “Infinite Recursion”?
a definition with a missing or badly written base case causes infinite recursion, similar to an infinite loop
avoided by making sure that the recursive call gets closer to the solution (moving toward the base case)
Define the term “Efficiency”.
A measure of the computing resources used by a piece of code such as time, memory, or disk space.
What is the efficiency of the following example?
for (N times) {
for (N times) {
statement1.
}
}
for (N times) {
statement 1.
statement 2.
}
N^2 + 2N
What is meant by shuffling data?
The task of rearranging its elements into a random order. Opposite of sorting.
What is a comparator?
Comparators perform comparisons between pairs of objects.
Name the two ways to determine an algorithm’s time efficiency?
Empirical Analysis
Algorithm Analysis
Define the term “Complexity Class”.
A category of algorithm efficiency based upon the algorithm’s relationship to the input data size.
Can a “Binary Search” be implemented using a recursive algorithm?
Yes.
Provide a high level description of the “Binary Search” algorithm.
Split the search space in two parts using a min, mid, and max indexes. Perform successive subdivisions of the search space until the target is found.
Provide a high level description of the “Selection Sort” algorithm.
Makes many passes over an input array to put its elements into sorted order.
Can a “Merge Sort” be implemented using a recursive algorithm?
Yes.
What is the complexity for a binary search?
O(log n)
What is the complexity for a hash function?
O(1)
What is the complexity for the following code segment?
for (int i = 0; i < N; i += c)
;
O(N)
What is the complexity for the following code segment?
for (int i = 0; i < N * N; i += c)
;
O(N^2)
What is the complexity for a merge sort?
O(n log n)
Define the term hashing?
To map a value to an integer index.
What is a hash table?
An array that stores elements via hashing.
What is a hash function?
An algorithm that maps values to indexes.
What is a collision?
When a hash function maps two or more elements to the same index.
Name three techniques for collision resolution?
Probing
Clustering
Chaining
What is a binary tree?
A tree where each node has at most two children.
What is the topmost node in the tree?
root
What is a leaf?
A node that has no children.
What is a branch?
Any internal node that is not a node or a leaf.
Name the three types of binary tree traversals?
Preorder
Inorder
Postorder
What are the four components in the Adapter Model?
Client, Target, Adaptor, Adaptee
What is the Java language equivalent of the JOptionPane?
System.out.println();
What are the two graphics packages available in the current Java release?
AWT and Swing.
Describe a two-way Adapter Model.
A two-way adapter supports both the Target and the Adaptee interface. It allows an adapted object (Adapter) to appear as an Adaptee object or a Target object.
Describe the motivations for using the Adapter Model?
Sometimes a toolkit or class library cannot be used because its interface is incompatible with the interface required by an application.
 We cannot change the library interface, since we may not have its source code.
 Even if we did have the source code, we probably should not change the library for each domain-specific application
What is a Frame?
A graphical window on the screen.
What is a Component?
A widget, such as a button or text field, that resides inside a graphical window.
What is a Layout Manager?
A Java object that decides the positions, sizes, and resizing behavior of the components within a frame or other container on the screen.
What is an Event?
An object representing a user’s interaction with a GUI component, which can be handled by your programs to create interactive components.
What is a Listener?
An object that is notified when an event occurs and executes code to respond to that event.
What is a metaphor for the Graphics object?
Think of the Graphics object as a pen and the panel as a sheet of paper.
What is the purpose of the following method?
public int getX();
Return the x-coordinate where the mouse event occurred.
What is the purpose of the following statement?
g.setColor(Color.RED);
To set the color of the next graphics object to RED.
There are new packages that you must import when writing graphical programs. Write the import statements necessary to use them.
import java.awt.*;
import javax.swing.*;
What class should be extended when drawing 2D graphics?
JPanel