1 / 2

Objects, Classes, & Methods (2.3)

Objects, Classes, & Methods (2.3). Computer Programming is basically the manipulation of data. How programmers manipulate data has changed from a top-down procedural programming methodology into Object Oriented Programming.

mura
Télécharger la présentation

Objects, Classes, & Methods (2.3)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Objects, Classes, & Methods (2.3) • Computer Programming is basically the manipulation of data. How programmers manipulate data has changed from a top-down procedural programming methodology into Object Oriented Programming. • In OOP, we define real world entities as user defined types called Abstract Data Types (ADT). • ADTs are the Objects in OOP representing Real World Entities. • Bank Accounts • Employee Records • Graphical Shapes • Etc… • A Classis the mechanism we use to define an Object (ADT) in Java. • A Class has the capability to encapsulate everything an Object needs to know about itself! • Objects can contain dataand the actions or behaviors to manipulate that data. • data -> Instance Fields • behavior ->Methods ( functions that manipulate data)

  2. Consider developing a BankAccountclass • Data (Instance Fields) -> might include – usually declared private: • balance -> myBalance • myPassword • myInterestRate • Behaviors (Methods) might include – usually declared public: • createAccount( ) • deposit( ) • withdraw( ) • viewBalance( ) • Every class has methods which can be called (invoked) by a class object (variable of a class). • Every Object belongs to a Class! • Class Variables - A class is usually stored as a separate file which is used in another program (Client Code). Class variables must be declared in-order for the Object to manipulate its data. BankAccount acct = new BankAccount( ); acct.deposit(depositAmount); • Manipulating an Objects data indirectly through public methods is referred to as Encapsulation or Data-Hiding. • We make an Objects data private to restrict direct outside access!

More Related