CS180 Final Exam Review - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

CS180 Final Exam Review

Description:

Object-Oriented Design (Chapter 1) Primitives. Objects, Classes, and Strings ... Off-by-one errors. Infinite looping. Overflow. Exceptions and Assertions ... – PowerPoint PPT presentation

Number of Views:37
Avg rating:3.0/5.0
Slides: 18
Provided by: Eliz193
Category:
Tags: cs180 | exam | final | offbyone | review

less

Transcript and Presenter's Notes

Title: CS180 Final Exam Review


1
CS180 Final Exam Review
  • December 8th, 2006

2
Final Exam Information At A Glance
  • Date
  • Tuesday, December 12th, 2006
  • Place
  • EE129
  • Time
  • 1020am 1220pm
  • Cumulative
  • Worth 20 of your final grade

3
Important Topics
  • Object-Oriented Design (Chapter 1)
  • Primitives
  • Objects, Classes, and Strings (Chapters 4 and 7)
  • Selection Statements (Chapter 5)
  • Repetition Statements (Chapter 6)
  • Exception and Assertions (Chapter 8)
  • Arrays (Chapter 10)
  • File I/O (Chapter 12)
  • Inheritance and Polymorphism (Chapter 13)
  • Generics (Supplemental Chapter)
  • Recursion (Chapter 15)
  • GUI and Event-Driven Programming (Chapter 14)

4
Object-Oriented Design
  • Methods
  • Extract small parts of a program and calculations
    which will be performed multiple times
  • Encapsulation
  • Classes, Objects, and Polymorphism
  • Covered in more detail later

5
Primitives
  • int, double, boolean, float, char, etc.
  • These are NOT Objects
  • Can be compared with , !, lt, gt, etc.
  • Cannot call methods
  • There is an Integer class, Character class, etc.
    which is different from a primitive
  • Explicit type-casting may need to be done
  • byte?short?int?long?float?double

6
Objects and Classes and Strings (oh my!)
  • Objects are handled with a reference address
  • Two objects can be compared with the .equals()
    method
  • Do NOT use to compare objects
  • Assignment operators assign references they do
    not make separate copies
  • Beware of NullPointerExceptions
  • Constructors should be used to initialize class
    variables
  • Methods in a class can only be called on an
    object of that class (or an object of a
    descendent of that class)
  • Keyword this

7
Objects and Classes and Strings (oh my!)
  • Strings are a type of object
  • Also cannot be compared with
  • Can be concatenated with the operator
  • Important String functions
  • charAt
  • indexOf
  • substring
  • length

8
Selection Statements
  • Modifies the flow of control of the program
  • if/else construct
  • Must have a boolean condition to check against
  • are important, but not necessary for one line
    statements
  • else branch is optional
  • switch construct
  • Multi-way branch which makes a decision based on
    a char, byte, short, or int
  • default case
  • break statement

9
Repetition Statements
  • for
  • while
  • do-while
  • Pitfalls
  • Off-by-one errors
  • Infinite looping
  • Overflow

10
Exceptions and Assertions
  • Use a try/catch/finally block to handle
    exceptions thrown by a program
  • Use throw statement to notify program of an error
  • Do not need to catch RunTimeExceptions
  • These should be checked for instead
  • User defined exceptions must extend Exception
  • Assert
  • Used for correctness

11
Arrays
  • Linear collection of data
  • Can hold primitives or Objects, but must all be
    of the same type
  • length tells the number of elements in the array
  • Member, not a method
  • Indexed from 0 to length 1
  • Protect against ArrayIndexOutOfBoundsException
  • Can create multiple dimension arrays
  • Usually use for-loops to iterate through members
    of the array

12
File I/O
  • Many classes
  • FileInputStream, DataInputStream, FileReader,
    BufferedReader, Scanner, PrintWriter,
    DataOutputStream, etc.
  • ObjectInputStream, ObjectOutputStream
  • Used to write objects to a file
  • Any object serialized by a stream must implement
    Serializable
  • Which classes are used to write text and which
    are used to write binary?
  • Always close files you open

13
Inheritance and Polymorphism
  • Differences between abstract classes and
    interfaces
  • Polymorphism can simplify code
  • Extend specific classes from general classes
  • Use protected keyword to protect information and
    methods
  • No need to rewrite methods which are the same as
    in a parent class
  • Superconstructor is always called as the first
    line of constructor

14
Generics
  • Commonly used for collections of objects
  • Can use bounded type to further restrict the type
    of object allowed
  • All Collections in Java use generics
  • Type safety can no longer put two completely
    different types of objects in the same collection

15
Recursion
  • Think about what the sub-problem is
  • Only be concerned with the current level of
    recursion
  • Two necessary cases
  • Base case
  • Recursive case

16
GUI and Event-driven Programming
  • Common classes
  • JFrame
  • JPanel
  • JLabel
  • JMenu, JMenuItem
  • JButton
  • You will not be asked to code a substantial GUI

17
Disclaimer
  • These slides are simply a review of the course
    material and are not meant to cover everything
    you may be responsible for knowing for the final
    exam
  • Complete sets of slides for both lectures and
    recitations can be found on the course webpage
Write a Comment
User Comments (0)
About PowerShow.com