CS 15-111
Final Exam
Review Sheets
The Structure of the Exam is as follows
-
Mutiple choice questions - 50% of the test
-
Writing cnew classes and methods - 30%
-
Tracing Code - 20%
The Best way to study for the test is to read the lecture notes, classwork
and review lab assignments. Given below is a sample set of questions.
The major topics covered in the test are:
-
Intro to classes, Methods and OOP
-
What is a class, object, Why
OOP? whats the difference with Procedural programming
-
Writing methods, using them
-
what is a method? Write the
following methods
-
Linked
List - insertLast(int n), insertFront(int n), insertInOrder(int n), delete(int
n)
-
Queues
- enqueue(int n), deque(), empty(), insertInOrder(n)
- insert to a priority queue - for example if n=1 then
-
insert new node at the end of all existing 1's.
-
Stack
- push(int n), pop()
-
Evaluate
any expression of postfix form using a stack
-
Array of Objects - declaring, initializing, processing,
printing
-
Define an account class and declare an array of Accounts. Initialize the
name of all to empty string and balance to 0
-
Write
the method insertInOrder(Account Obj) that inserts the Account object
in alphabetical order
-
Write
the method reverse() that reverses the entire array
-
Search - linear and binary - iterative and recursive
implementation - comparison of searching algorithms
-
Write both linear and binary search functions - iteratively and recursively
-
What
are the differences in linear and binary search algorithm. Can they be
applied to any data set
-
Sorting - Bubble, selection, and quicksort - comparisons
- analysis
-
Which
is the better algorithm? What role the data set plays? No proofs will be
tested
-
Understand
each algorithm well. You may be asked to write the code for any of the
methods
-
Be sure that you know how to step thru a quicksort algorithm
-
I/O - reading from standard input and file input,
writing to standard output and file output
-
Just
read the notes here. Only MCQ's will be given
-
Inheritance - concept and examples -
-
Why is inheritance? Why is it important to OOP? Give an example of deriving
a SavingsAccount class from
-
an Account class. What is super? What is polymorphism? How do we classify
the relationship between two
-
objects
as an inheritance relationship?
-
Graphs - definition, representation - adjacency
matrix and adjacency list - inserting nodes, edges, deleting nodes, edges,
updating nodes and edges.
-
What is a graph, Leanr all the definitions discussed in class. Do
you know how to traverse a graph? Understand
-
both
representations of the Graph. You should be able to write any of the above
methods in each representation
-
Linked Lists - definition, creating, inserting,
deleting nodes, printing a list (backwards), recursive processing of a
list
-
Define
a node class and its constructors. Show how you build an ordered linked
list using a file of ints
-
Binary Search Trees - Definition, implementation,
inserting nodes, deleting nodes, searching tree, traversing a tree
-
Study the methods: insert(int n), delete(int n), print -inorder, postorder,
preorder
-
Applets and GUI's - short questions only.
NO QUESTIONS WILL BE ASKED HERE
===========================================================================
TOPICS FROM TEST1
-
Describe the problem solving process? Why do we design before coding?
-
Compare OOP vs Procedural?
-
Describe the problem solving process and OO design.
-
Identify classes and objects in a ATM system.
-
Describe a set of methods for each of the class defined above.
-
Explain the standard Java class template:
Import <package-name>.*;
Public class <class-name> extends <some other class>
implements <an interface>{
//declaration of instance variables
Private <data-type> <name>
Public <class-name>() {
} // constructor method
Public <return-type> <method-name> ( <parameter-list>)
{
}
}
-
Define the terms, package, class, methods, private, public, protected,
object
-
What are the three types of class relationships?
-
Describe the Java primitive data types, and java reference types.
-
Why do we throw an exception?
-
What is the purpose of new operator?
-
Give examples of the use of Java, if statment, for loops, while loop, switch
statment
-
How do we declare arrays in Java? How do we read data into an array? How
do we access them?
-
Write a Java code segment that will interactively read a set of integers
into an array, and find its their sum and average.
-
Write code to sort an array of integers. Write code to reverse an array.
-
How do we declare matrices? How do we use them?
-
Write a code segment to return true if A[i][j] = A[j][i] for all
i and j
-
What are some of the methods from vector class? How do we use them? You
dont have to memorize these? But know how to use them? Why do we use a
vector as opposed to an array?
-
Explain the standard method template
access_modifiers method_modifiers return_type method_name(
parameter_list )
{
method body
}
-
How does Java assign memory for class methods, and objects?
-
What is a default constructor? Specific constructor? Give an example of
each for Elevator class.
-
What are accessors? Mutators? Give an example of each.
-
What are subclasses and superclasses. Give an example in terms of Account
class and SavingAccount class.
-
What is "this"?
-
Write a method compareTo, that takes an elevator object and return true
if it is equal to the instance object, else retrun false..
===============================================================================
TOPICS FROM TEST 2
Lecture Notes:
Lecture 08- The Set Class
- know the definition of a set, how to write
new constructors and methods
Lecture 09 - Linear and Binary Search
- Study the algorithm for linear and binary
search, what are their complexities, what are the preconditions under each
one can be applied
Lecture 10 - Sorts
- study the bubble sort and selection sort
algorithms, write 3 versions of the bubble sort algorithm, why is selection
sort better than bubble sort, what is quick sort, what are the complexities
of each algorithm, sometimes quick sort is worse than the other two, when?
Lecture 11 - IO
- study the ways to read input from keyboard, and
from files, how do we write data to screen and external files. Undersand
the process in each instance.
Lecture 12 - Inheritance and Polymorphism
- why is inheritance important. Design an animal
class and show how you can derive new classes, cow and rabbit. (use at
least one constructor, one instance variable, one method in each)
TextBook References
pages 435, 45, 32, 35, 37, 38, 39, 40, 46-50,....
Lab Skills
1. How to design a new class (eg:set) and write constructors, and methods
(lab3)
2. How to read a file into an array, manipulate (search, sort) and
write output to a file.(lab4)
MULTIPLE CHOICE
The following topics will be covered in this section. Know the definitions
of class, object, methods, public, private, program, ,model., library,
references, messages, identifier, java byte code, String objects, signature,
prototype, assignment statement, varaible, constructor, new operator, interactive
data, disk files, reading from a disk file, writing to a disk file, exceptions,
network computing, static methods, primitive data types, base class, inheritance,
multiple inheritance, super, derived class etc.
WRITE NEW METHODS
1. Consider the Set class considered in lab3. Add a new constructor
that will take one argument(int array) and create a set using the values.
2. Add a new method to the Set class, average, that returns the average
of the set of integers.
3. Design a class Circle, with the following. 2 constructors, accessor
methods, getCenter, getRadius, area, resize
3. Design a new class, Account with instace variables, balance, accountNumber,
and methods deposit, withdraw, balanceInquiry
and at least two constructors. Derive a new class,
mutualFund from Account class.
TRACE THE CODE
1. . What is the purpose of the following method?
boolean double foo(int x) {
return (x >
0) ;
}
2. What is the purpose of the following method?
public void printFile(File f){
try {
FileOutputStream fstream
= new FileOutputStream(f);
PrintStream target = new
PrintStream(fstream);
for (int i=0;i<array.size();i++)
target.println(array.elementAt(i));
}
catch (FileNotFoundException e)
{
System.out.println("File not found.");
}
}
=====================================================================
©Copyright 2001 Ananda Gunawardena.
All rights reserved.
This document was last updated on 08/15/01
23:22:56