lecture 20 april 13, 2000. review for exam all exercises and sample code from lectures object based...
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](https://reader036.vdocuments.us/reader036/viewer/2022082819/56649f1d5503460f94c34bcd/html5/thumbnails/1.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022082819/56649f1d5503460f94c34bcd/html5/thumbnails/2.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022082819/56649f1d5503460f94c34bcd/html5/thumbnails/3.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022082819/56649f1d5503460f94c34bcd/html5/thumbnails/4.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022082819/56649f1d5503460f94c34bcd/html5/thumbnails/5.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022082819/56649f1d5503460f94c34bcd/html5/thumbnails/6.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022082819/56649f1d5503460f94c34bcd/html5/thumbnails/7.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022082819/56649f1d5503460f94c34bcd/html5/thumbnails/8.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022082819/56649f1d5503460f94c34bcd/html5/thumbnails/9.jpg)
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](https://reader036.vdocuments.us/reader036/viewer/2022082819/56649f1d5503460f94c34bcd/html5/thumbnails/10.jpg)
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 ]