lecture 20 april 13, 2000. review for exam all exercises and sample code from lectures object based...

10
Lecture 20 April 13, 2000

Upload: christian-watkins

Post on 04-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 20 April 13, 2000. Review for Exam All Exercises and Sample Code from Lectures Object Based Programming Object Oriented Programming String and

Lecture 20

April 13, 2000

Page 2: Lecture 20 April 13, 2000. Review for Exam All Exercises and Sample Code from Lectures Object Based Programming Object Oriented Programming String and

Review for Exam

• All Exercises and Sample Code from Lectures• Object Based Programming• Object Oriented Programming• String and StringBuffer Operations• Input/Output• Exception Management• Event Management• GUI Design

Page 3: Lecture 20 April 13, 2000. Review for Exam All Exercises and Sample Code from Lectures Object Based Programming Object Oriented Programming String and

Object Based Programming

• Reference Variables• Objects hold instance fields and a reference to the

class object.• Class objects hold static fields, pointers to both

static and instance methods, and a reference to the direct superclass object.

• Static, instance, local, and block-local variables.• Public, private, and package access.

Page 4: Lecture 20 April 13, 2000. Review for Exam All Exercises and Sample Code from Lectures Object Based Programming Object Oriented Programming String and

Object Oriented Programming

• Class Hierarchies– The “isa” relationship– Inheritance of methods and fields

• Exercise 5

– The super keyword– The super() method– Protected access

• Classes and Interfaces– Defining vs Declaring– Abstract Classes

Page 5: Lecture 20 April 13, 2000. Review for Exam All Exercises and Sample Code from Lectures Object Based Programming Object Oriented Programming String and

String and StringBuffer Operations

• Exercises 6a and 6b

• Mutable or not

• Relative Efficiency

• Methods Available

Page 6: Lecture 20 April 13, 2000. Review for Exam All Exercises and Sample Code from Lectures Object Based Programming Object Oriented Programming String and

Input/Output

• Class java.io.File• Classes for reading/writing characters

– BufferedReader, FileReader– BufferedWriter, FileWriter

• Classes for reading/writing bytes– FileInputStream– FileOutputStream

• Need to close output files.

Page 7: Lecture 20 April 13, 2000. Review for Exam All Exercises and Sample Code from Lectures Object Based Programming Object Oriented Programming String and

Exception Management

• An Exception is …– The Exception class hierarchy.– Checked/Unchecked exceptions.

• The throw, throws, try, catch, and finally keywords.

• The @throws javadoc tag.

Page 8: Lecture 20 April 13, 2000. Review for Exam All Exercises and Sample Code from Lectures Object Based Programming Object Oriented Programming String and

Event Management

• An Event is …– Event classes

• Event Listener Interfaces

• Event Adapter Classes

• Callback Methods

• Using anonymous classes to define listener objects.

Page 9: Lecture 20 April 13, 2000. Review for Exam All Exercises and Sample Code from Lectures Object Based Programming Object Oriented Programming String and

GUI Design

• Classes– JFrame– JMenuBar– JMenu– JMenuItem

Page 10: Lecture 20 April 13, 2000. Review for Exam All Exercises and Sample Code from Lectures Object Based Programming Object Oriented Programming String and

Action Listener Strategies• Simple is Better …

– Separate Listeners for Each Active Component• Simple: Each actionPerformed() method deals only with

events from a particular component.• Complex: There can be a lot of actionPerformed() methods,

each with its own (anonymous) class.

– One Listener for All Events• Simple: Only one actionPerformed() method.• Complex: The actionPerformed() method must test each

ActionEvent to see which component it came from, and then branch to the appropriate code for that component.

• [ ActionListener_ex.java ]