Shared Flashcard Set

Details

Java programming
Concepts in Java
86
Computer Science
Undergraduate 1
04/25/2009

Additional Computer Science Flashcards

 


 

Cards

Term
Object
Definition
An object encapsulates state and behavior
Term
Generic Class(Generic)
Definition

A class such as ArrayList that takes a type parameter to indicate what kind of values will be used.

 

 

An object in java that accepts another type as part of itself

Term
Wrapper Class
Definition
A class that "wraps" primitive data as an object
Term
Boxing
Definition
An automatic conversion from primitive data to a wrapped object of the appropriate type (e.g. an int boxed to form an Integer)
Term
Unboxing
Definition
An automatic conversion from a wrapped object to its corresponding primitive data (e.g. an Integer unboxed yields an int)
Term
Comparison Function
Definition
A well-defined procedure for deciding, given a pair of values, the relative order if the two values
Term
Natural Ordering
Definition
The order imposed on a type by its comparison function
Term
Collection
Definition
An object that stores a group of othert objects, called its elements
Term
Linked List
Definition

A collection that stores a list of elements in small object containers called nodes, which are linked together.

 

Strengths: excells in add/removes

Weaknesses:  No random access

 

 

Term
Iterator
Definition
An object that allows you to efficiently retrieve the elements of a list in sequential order
Term
Abstract Data Type (ADT)
Definition

A specification of a type of data and the operations that can be performed on it.

 

 

  • Cannot be instantiated

 

Term
Set
Definition
A collection that stopres a group of elements and prevents duplicates and can be searched efficiently
Term
Map
Definition
A collection that associates objects called keys with objects called values in wghich each key is associated with a corresponding value.
Term
Iteration (Iterative)
Definition
A programming technique in which you describe actions to be repeated using a loop
Term
Recursion (Recursive)
Definition
A programming technique in which you describe actions to be repeated using a method that calls itself
Term
Base Case
Definition
A case that is so simple it can ber solved directly without a recursive call.
Term
Recursive Case
Definition
A case that involves reducing the overall problem into a simpler problem of the same kind that can be solved by a recursive call.
Term
Call Stack
Definition
The internal structure that keeps track of the sequence of methods that have been called.
Term
Inheritance (Inherit)
Definition
A programming technique in which a derived class extends the functionality of a base case, inheriting all of its state and behavior
Term
Superclass
Definition
The parent class in an inheritance relationship
Term
Subclass
Definition
A child class in an inheritance relationship
Term
Override
Definition
To implement a new version of a method to replace code that would otherwise have been implemented from a superclass.
Term
Polymorphism
Definition
The ability for the same code to be used with several different types of objects and behave differently depending on the actual type of object used.
Term
Substitutability
Definition
The ability or ab object of a subclass to be used succesfully anywhere an object of the superclass is expected.
Term
Has-a Relationship
Definition

A connection between two objects where one has a field that refers to the other. The contained object acts as part of the containing objects state.

 

Term
Interface
Definition
A set of methods that classes can promise to implement, allowing you to treat those classes similiarly in your code.
Term
Abstract Method
Definition
A method that is declared (as an interface) but not implemented.  Abstract methods represent the behavior a class promises to implement when it implemements an interface.
Term
Object-Oriented Design (OOD)
Definition
Modeling a program or system as a collection of cooperating objects, implemented as a set of classes using class hierarchies
Term
Abstract Class
Definition
A java class cannot be instantiated, but instead serves as a superclass to hold common code and declare abstract behavior.
Term
What is the difference between the "client view" and the "implementer view"?
Definition
External client view is the "what" part and the implementer view is the "how" part.
Term
What method is called in the ArrayList class to dynamically include new items?
Definition
the add method
Term
In the ArrayList class describe the use of the contains() method
Definition
returns TRUE if a given element is in the list
Term
What method is called in the ArrayList class to dynamically eliminate items
Definition
remove()
Term
In the ArrayList class describe the use of the size() method
Definition
returns the number of elements
Term

What is the problem with the following code:

 

for (String s:Words)

{

     if (s.equals("hello"))

     {

         Words.add("goodbye");

     }

}

Definition

You cannot change the list in any way while iterating through it with the "for each"

 

Term

What is the problem with the following code:

ArrayList numbers = new ArrayList();

 

Definition
The "int" cannot be primitive types, must be objects!  i.e. "Integer"
Term
Which interface is used to implement object comparison?
Definition

Comparable

 

???? NEED MORE INFO ???

Term
What is the name of the frameworkk that is largely contained in the package java.util
Definition
Java Collections Framework
Term
What is a Queue?
Definition
A collection where elements are removed in the order they were added (FIFO)
Term
What is a List?
Definition
An ordered collection of elements accessed by integer indexes
Term
What is a stack?
Definition
A collection where the last element added is the first one to be removed
Term
12 methods of the Collection interface
Definition

 

 

  1. add(element)
  2. addAll(collection)
  3. clear()
  4. contains()
  5. containsAll()
  6. isEmpty()
  7. iterator()
  8. remove(element)
  9. removeAll(collection)
  10. retainAll(collection)
  11. size()
  12. toArray()

 

Term
3 Methods of Iterator Objects
Definition

  1. hasNex()
  2. next()
  3. remove()

Term
2 Benefits of ArrayList
Definition

  1. random access: an element can be accessed quickly
  2. adding and removing at the end of the list is fast

Term

4 Benefits of LinkedList

Definition

  1. adding and removing at either end is fast
  2. fast add/remove suring a sequential access with an iterator
  3. no need to expand an array when full
  4. can be more easily used as a queue

Term
11 Useful static methods of Collections class
Definition

  1. binarySearch(list,value)
  2. copy(destinationList, sourceList)
  3. fill(list,value)
  4. max(list)
  5. min(list)
  6. replaceAll(list,oldValue,newValue)
  7. reverse(list)
  8. rotate(list,distance)
  9. shuffle(list)
  10. sort(list)
  11. swap(list,index1,index2)

Term
2 Strengths of the HashSet
Definition

 

  1. extremely fast performance for add, contains, remove
  2. can be used with any type of objects as its elements

 

Term

2 Strengths of the TreeSet

Definition

  1. elements are stored i sorted order
  2. must be used with elements that can be compared.

Term
4 common set operations
Definition

  1. union -- addAll
  2. intersection  -- retainAll
  3. difference -- removeAll
  4. superset,subset -- containsAll

Term
11 useful methods of Maps
Definition

  1. clear()
  2. containsKey(key)
  3. containsValue(value)
  4. get(key)
  5. isEmpty()
  6. keySet()
  7. put(key,value)
  8. putAll(map)
  9. remove(key)
  10. size()
  11. values()

Term

Comparison of ADT and interface name

Lists:   What are the 2 implementations?

Definition

  1. ArrayList
  2. LinkedList

Term

Comparison of ADT and interface name

Set:   What are the 2 implementations?

Definition

  1. HashSet
  2. TreeSet

Term

Comparison of ADT and interface name

Map:   What are the 2 implementations?

Definition

  1. HashMap
  2. TreeMap

Term

Comparison of ADT and interface name

List: What is(are) weaknesses? (2)

Definition
slow to search,slow to add/remove arbitrary elements
Term

Comparison of ADT and interface name

Set: What is(are) weaknesses? (2)

Definition
does not have indexes; cannot retrieve arbitrary elements from it
Term

Comparison of ADT and interface name

Map: What is(are) weaknesses? (2)

Definition
not a general purpose collection; cannot easily map backward from a value to its key
Term
Weakness of a TREESET?
Definition
must use Comparable interface
Term
Is-a Relationship
Definition
A hierarchical connection between two categories where one type can be treated as a specialized version of the other
Term
Inheritence Hiearchy
Definition
A set of hiearchical relationships between classes of objects
Term
What is the purpose if the binarySearch(list value) method of the Collections class?
Definition
quickly searches a sorted list and returnes the element its index 
Term
Searching
Definition
The task of attempting to find a particular target value in a collection or an array.
Term
CH 13| Sorting
Definition
The task of arranging the elements of a list or an array into natural ordering
Term
CH 13| A Comparator object...
Definition
describes a customized way to compare objects, enabling arrays or lists of these objects to be searched and sorted in many orders
Term
CH 13| Empiral Analysis
Definition
The technique of running a program or algorithm to determine it's runtime. 
Term
CH 13| Algorithm Analysis:
Definition
the technique of examining an algorithm's code or pseudocode to make inferences about its efficiency.
Term
CH 13| Sequential Search
Definition
An O(N) searching algorithm that looks at every elemement of a list until the target is found.
Term
CH 13| Binary Search
Definition

is an O(log N) searching algorithm that operated on a sorted dataset and sucessively eliminates half of the data until the target element is found.

 

Term
CH 13| Selection sort
Definition
Selection sort is an O(N^2) sorting algorithm that repeatedly finds the smallest unprocessed element of the array and moves it to the frontmost remaining slot in the array
Term
CH 13| Merge sort
Definition
Merge sort is an O(N log N) sorting algorithm often implemented recursively, that sucessively divides the dataset into two halves, recursive soorts the halves, and then merges the sorted halves into a sorted whole.
Term
CH 13| Efficiency
Definition
A measure of the computer resources used by a piece of code such as time, memory, or disk space.
Term
CH 13| Complexity Class
Definition
A category of algortih efficiency based upon the algorithm's relationship to the input data size.
Term
CH 13| Constant-time Complexity Class
Definition
O(1) - Those whose runtimes dont sepend on the input size such as code to convert a value from Farenheit to celcius
Term
CH 13| Logarithmic or O(log N) Complexity Class
Definition
Algorithms that typically divide a problem space in half repeatedly until the problem is solved.  Binary search is an example.
Term
CH 13| Linear or O(N)
Definition
algorithms are those whose runtimes are directly proportional to N... i.e. rouchly double when N doubles.
Term
CH 13| Log Linear or O(N log N)
Definition
algorithms typically perform a combination of log and linear operations, such as executing a log function over every element of a dataset of size N.  Many efficient sorting algoithms, such as merge sort are log-linear
Term
CH 13| Quadratic of O(N^2)
Definition
alg. are those whose runtimes are proportional to the square of the the input size.  This means that quardatic alg. runtimes roughly quadruple when N doubles,
Term
CH 13| Cubic O(N^3)
Definition
alg. are those whose runtimes are proportional to the cube of the input size.
Term
CH 13| Exponential or O(2^N)
Definition
alg are those whose runtimes are proportional to 2 raised to the power of the input size.  This means if the input size increases by just one, the algo. will take twice as long to execute. 
Term
Chap 14|Frame
Definition
A graphical window on a screen
Term
Chap 14|Component
Definition
A widget, such as a button or a text field, that resides inside a graphical window
Term
Chap 14|Layout Manager
Definition
A Java object that decides the positions, sizes, and resizing behavior of the components within a frame or other container on the screen
Term
Chap 14|Event
Definition
An object representing a user's interaction with a GUI component, which can be handled by your programs to create interactive components.
Term
Chap 14|Listener
Definition
An object the is notified when an event occurs and executes code to respond to that event.
Term
Chap 14|Composite Layout
Definition
A layered layout using several layout managers in different nested containers
Supporting users have an ad free experience!