CS 15-111
Exam Two
Study Topics
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