Class and Objects in Java
Click :---Java Object in Hindi
Click:---Java Class in Hindi
Introduction to java class and Object
Class and Objects important parts of oops.
Look at the following Example represent through diagram.
Class | Objects |
Fruits | Apple |
Banana | |
Mango | |
Papaya |
Same As Another Example :-
Class | Objects |
Students | Shailesh |
Annu | |
Smriti | |
Kajal |
Class
- It is a collection of data members and member functions.
- Data members are the variable used inside class.
- Member functions are the function used inside class.
- It is also called Userdefined data type.
Object
Object :- Object is a real world entity.
- Object is having states and behaviors in which state means what does it has and behavior means what does it do. for example a pen has
- States:ink,nib,needle,cap etc
- Behaviors:Writing.
Impotent point to remember while making class program
⇒Declare variable with appropriate data type as per your requirement
⇒Declare function as per your requirement
⇒Create instance(object) of class to access the data member and member function of a class.
⇒Accessing data member and member fucntion
⇒Accessing data member
⇒Accessing member function
Comments