Information on Test 1, CS2110, Spring 2011
Monday, 2:10pm
The test will be held on Wednesday, Feb. 16, in class at your
regular class-meeting time.
Be sure to come on time!
Readings from
the MSD textbook:
- Chapter 1 (all sections)
- Chapter
2
- but not Section 2.3.2 on
UML
- Chapter
3 (except some sections -- see below)
- Some pages from Chap. 6 on Comparable, Comparators, etc.
- Additional topics from slides:
see below
All slides from this part of the
course:
Topics in readings that won't be
on the test:
- No questions on these topics mentioned
in Section 1.2.4:
threads, graphical user interfaces, networking.
- Section 3.2: nothing on nested classes,
inner classes, or package scope. Nothing on Javadoc.
- Section 3.4:
- You can stop reading in the middle of page 161 when they start
to talk about generic methods.
- Note that we used a generic with a class (like the Enclosure
example) when we created a class for Comparable.
There might be coding questions
(large or small) on
the following:
- Create a class with specified methods and fields
- Write methods like equals() or compareTo() or compare() for a
class we describe to you
- Do operations using ArrayLists of objects like things you did in
HW0 and HW1
- add objects, find objects, alter the list, do something to
items in the list, etc.
- Write a class that implements Comparator
Summary
of topics:
Java Review and Issues:
- Class concepts (slides and Chapter 3)
- Primitive
types vs. object references
- Object references
(This is in both Chap. 2 and Chap. 3)
- equals()
vs. == and also how to write equals()
- types of
identity/equivalence
- Comparable and Comparator: see slides or pages 641-647 in the MSD
book
- these are interfaces, so know what methods are in the interface
- how to write classes that implement them
- how to use these when sorting with Collections.sort()
- Arrays -- no direct questions
on arrays!
- ArrayList -- you may have to use these in your answers on other
topics
- Scanner-- no direct questions
on Scanner!
- Review
info on Java methods in Section 3.2.2
- No
questions on garbage collection or destructors
- No questions on these topics: Exceptions, URL class,
reading from files
SW Engineering,
Chap. 1:
- What issues are more important in
Software Engineering (SE) in industry than in programming-in-the-small
(i.e. what we do in class)?
- Phases in the software
development lifecycle
- Relative costs per phase
(general)
- Importance of front-end phases (why?
FYI, "front-end"
means "before implementaton")
- Problem specifications or requirements
- Focused on the problem, users but not the solution
- Challenges related to
requirements.
- Functional, non-functional, constraints,
implementation bias decisions (made by
the customer)
- Design (see the textbook
for some of this)
- CRC cards
- subclasses, abstract classes, interfaces,
error conditions/exceptions
- Execution-based
Testing
- Principles,
ideas, Dijkstra's quote (and its point)
- All definitions from
testing
- What's
a test-case
OO
Design and Programming, Chapters 2 and 3:
- Principles of the OO approach
- Objects have:
state, behavior, identity
- Objects have
responsibilities, static and dynamic links to other objects.
- Reference variables to objects
- content
equivalence vs. name equivalence
- Basics
of inheritance (terms, ideas, the idea of "Is-A", substitutability)
- Motivations
for inheritance
- See slides that introduce
inheritance
- Extending a
class
- Adding new fields or methods
- Over-riding
methods
- The use of the protected
visibility keyword for fields and methods in superclasses.
- Java's class Object and some of its methods
(toString, equals, but no questions on hashCode)
- Why
we must have an Object parameter-type when over-riding boolean equals(Object o)
- Using a superclass
reference to point to subclass objects
- Run-time polymorphism and references of the
superclass type
- At run-time, the method defined
in the subclass will be chosen and called
Interfaces
- What is
multiple inheritance? Java doesn't support it, but does allow
interfaces
The "forms of
inheritance" listed on pp. 53-55 and in slides.
- Specifically specialization vs. specification
Abstract
classes -- defined only for creating subclasses by extension; not
possible to create an instance
Methods in String
and ArrayList I'll Assume You Know
String class
int compareTo(String anotherString) --
Compares two
strings lexicographically.
boolean contains(CharSequence s) --
Returns true if
and only if this string contains the specified sequence of char
values. (A String "is-a" CharSequence.)
int indexOf(String str) --
Returns the
index within this string of the first occurrence of the specified
substring.
int length() --
Returns the
length of this string.
String substring(int beginIndex) --
Returns a new
string that is a substring of this string.
String substring(int beginIndex, int endIndex) --
Returns a new
string that is a substring of this string.
String toLowerCase() --
Converts all of
the characters in this String to lower case
String toUpperCase() --
Converts all of
the characters in this String to upper case
String trim() --
Returns a copy
of the string, with leading and trailing whitespace omitted.
ArrayList<E> class
Constructor: ArrayList<E>(another-array-List) --
creates a new
list that contains all the elements in the specified list
boolean add(E e) --
Appends the
specified element to the end of this list.
void clear() --
Removes all of
the elements from this list.
boolean contains(Object o) --
Returns true if
this list contains the specified element.
E get(int index) --
Returns the
element at the specified position in this list.
int indexOf(Object o) --
Returns the
index of the first occurrence of the specified element in this list, or
-1 if this list does not contain the element.
E remove(int index) --
Removes the
element at the specified position in this list.
boolean remove(Object o) --
Removes the
first occurrence of the specified element from this list, if it is
present.
int size() --
Returns the
number of elements in this list.