CS 1713-001 Introduction to Computer Science
Spring 2001 -- Review for Final Exam
(Tuesday, 8 May 2001,
8:00 - 10:15 am)
Things you will not be tested on:
- No Graphics (including no applets and
no paint)
- No Two-dimensional arrays
- No File I/O (not covered in class, but used in examples)
- No Vectors (not mentioned in class)
Topic covered on the final include:
- the basics (loops and if-else),
- strings,
- classes (defining classes, creating them, using them),
- arrays (including arrays of objects),
- interfaces (used especially for sorting), and
- class hierarchies (using inheritance).
Details about topic that will be covered on the final:
- The if-else statement. (Remember the rule
that an else matches the nearest unmatched
if, except that one should always use extra
braces {} to avoid having to apply the rule.)
NO PRACTICE PROBLEM IN THIS CASE.
- for loops. (These have many uses, but are
particularly useful in conjuction with arrays.)
Here is a practice problem:
for loop problem.
- while loops. (This is the workhorse of
loops in Java. Remember that you can use break
to terminate a while loop.)
Here is a practice problem:
while loop problem. (Actually more of
a for loop problem.)
Solution.
(Don't access until you've tried the problem.)
- Strings. (Remember that strings in Java
are objects, not primitive data types, and as such there
are a number of methods for working with strings. Given two
strings String s1, s2;, you would not normally
compare them for equality with s1 == s2, but instead with
s1.equals(s2). Similarly, use
s1.compareTo(s2) to compare strings using alphabetic
order.)
Here is a practice problem:
Problem involving strings.
Solution.
(Don't access until you've tried the problem.)
- classes. (You need to be able to define a class,
giving data fields, constructors, and various methods. Then you
you need to be able to use new to create instances
of the class, and use class methods to do things.)
Here is a practice problem:
Problem involving classes.
Solution.
(Don't access until you've tried the problem.)
- arrays. (Arrays are used to hold collections of identical
data. We have worked with arrays of primitive types as well
as arrays of objects.)
Here is a practice problem:
Problem involving arrays
of a primitive type.
Solution.
(Don't access until you've tried the problem.)
- interfaces. (You should know how to implement
an interface for a class, and how to use and interface like
Comparable and a sort like
insertionSort to sort an array of objects into order.)
Here is a practice problem:
Problem involving interfaces.
Solution. (Sorted by decreasing GPA.)
(Don't access until you've tried the problem.)
Solution. (Sorted by increasing
class code and then by name.)
(Don't access until you've tried the problem.)
- class hierarchies. (The most important part of object-oriented
programming is to use inheritance to define a new class from an
existing own, where the new class extends
the old one.)
For practice problems see the Week 14 lectures:
Week 14 lectures.
Solution
(to the first part).
(Don't access until you've
tried the problem.)
- for loops, arrays and Strings.
Here is a more interesting practice problem:
12 days of Christmas.
Solution.
(Don't access until you've tried the problem.)
Revision date: 2001-04-28.
(Use ISO 8601,
an International Standard.)