OOPs (Object oriented programming) is based on two concepts: -
Objects and Classes
Objects and classes provide a better way to design the system.Objects :-
There are three basic properties of an object-- State :- state represent the data in the object. it can't change after creation.
- Behavior :- Behavior represent the method in the objects by which the object can be used. Behavior can change.
- Identity :- it is the property of object that distinguishes it from other objects.
Classes :-
Class is a blueprint from which an object is constructed. It is a group of objects with common attributes. Class contains-- members of class
- method
class <class_name>
{
members of class
methods} |
Sample of a class :-
class Example
{
String name;
int age;
void display()
{ }
void hide()
{ }
}
|
No comments:
Post a Comment