COP 4331 OOD - PowerPoint PPT Presentation

About This Presentation
Title:

COP 4331 OOD

Description:

TYJ Day 6 Packages. Package. Collection of related classes ... Method sleep() Classes using threads implement the Runnable interface. Must have run() method ... – PowerPoint PPT presentation

Number of Views:41
Avg rating:3.0/5.0
Slides: 12
Provided by: roybl
Learn more at: https://www.cse.fau.edu
Category:
Tags: cop | ood | runnable

less

Transcript and Presenter's Notes

Title: COP 4331 OOD


1
COP 4331 OODP
  • Lecture 3

2
TYJ Day 5 Creating Classes
  • General structure of classes
  • The Class Declaration
  • The Class Body
  • Constructors
  • this and super
  • Declaring Member Variables
  • Method Declaration , Parameters, Method Body
  • Implementing Methods
  • Access Control

3
Some Classes
  • Index of all classes
  • class Object
  • class Integer
  • class String

4
TYJ Day 6 Packages
  • Package
  • Collection of related classes
  • Default access privilege
  • In a single directory
  • Import eliminates need for full package
    qualification
  • import java.util.Vector
  • import java.awt.

5
TYJ Day 6 Interfaces
  • Interface
  • Workaround for multiple inheritance
  • Specifies functions that must be defined in an
    implementing class
  • A class implements an interface

6
TYJ Day 6 Inner Classes
  • Inner class
  • Defined inside another class
  • Can only be used inside that class

7
TYJ Day 7 Exceptions.1
  • Mechanism to handle
  • Errors
  • Unusual situations
  • Exception classes
  • Error (major errors)
  • Exception (less serious)
  • Runtime exceptions
  • Other exceptions

8
TYJ Day 7 Exceptions.2
  • classs Throwable
  • class Error
  • class Exception
  • Exception handling
  • try catch
  • Methods that throw exceptions
  • The throws clause documents that a method may
    throw a specified exception that must be caught
    or specified further

9
TYJ Day 7 Exceptions.3
  • Throwing and defining exceptions
  • The throw statement
  • Creating exception subclasses

10
TYJ Day 7 Threads.1
  • Threads allow several portions of a program to
    run concurrently
  • Designing effective threaded programs can be
    quite complex
  • Beyond the scope of this course
  • But some Java programs use threads in a set way

11
TYJ Day 7 Threads.2
  • Threads are implemented in class Thread
  • Method start() starts thread
  • Method sleep()
  • Classes using threads implement the Runnable
    interface
  • Must have run() method
Write a Comment
User Comments (0)
About PowerShow.com