09-05-2013, 03:38 PM
OOP Concepts
OOP Concepts.ppt (Size: 555.5 KB / Downloads: 21)
What Are Classes?
Definition:
A class is a blueprint or prototype
Defines the variables and methods common to all objects of a certain kind.
The Benefits of Classes
Reusability -- Software programmers use the same class, and the same code to create many objects.
Anatomy of a class
In a Java program everything is encapsulated in a class.
A class is a user defined data type.
Class defines the state and behavior of objects.
Once class type has been defined, we can create “variables” of that type.
These are known as instances of a class
Adding methods
A class without methods that operate on data has no “life”.
The objects created by such a class cannot respond to any messages.
Therefore add methods that are necessary for manipulating data contained in the class.
What Are Messages?
Message in an object.
Software objects interact and communicate with each other by sending messages to each other.
Messaging
Three components comprise a message:
The object to whom the message is addressed (Your Bicycle).
The name of the method to perform (changeGears).
Any parameters needed by the method (lowerGear).