Computer Science (CSCI) Department
College of Engineering, Computer Science, & Technology (ECST)

JETT Workshops
Object-Oriented Programming

Fall 2004

Classes and Objects
are fundamental concepts of
Object-Oriented Programming (OOP)

(Example code and figures from Computing Concepts with Java Essentials, 3rd edition, by Cay Horstmann.
Visit www.wiley.com/college/horstmann for information on the current edition of this excellent text.)

Encapsulation = Hiding data and providing access & behaviors through methods

Exercise - modify the BankAccount class

  • pick a programming environment
  • set up the BankAccount project
  • play with the program
    • create some more BankAccount objects in BankAccountTest
    • call methods to deposit and withdraw
    • get the balance for each and print it
  • modify the BankAccount class
    • add an instance variable to store the account owners name
    • add an appropriate accessor method
    • supply an appropriate constructor
    • modify the test class to test this new functionality
  • solution - no peeking until yours works!