Class Concept in Java Programming | Explained with Real Life Example :
Consider Person as a class. Now we can have some properties associated with this class Person such as
Attributes of Person :
- Name of Person
- Gender
- Skin Color
- Hair Color etc.
Now these are the general properties which forms template of the class Person,and above properties of the are called as Attributes of the Class.
Now Person class may have some core functionality such as –
- Talking
- Walking
- Eating
Thus in short Class have –
- Class name
- Properties or Attributes
- Common Functions
Now ,we are going to create objects of the class , i.e actual instance of the class. Let us say that we have created objects such as “Ram”,”Sam”. Both will have same attributes and functionality but have different attribute value
Now this is just a template , called as “Class” , and Object is instance of the class.
Summary : Class Concept in Java Programming (Quick Look Class)
Syntax of Class :
- A Class is a blueprint or a template to create objects of identical type.
- A Class is core concept of Object Oriented Programming Language.
class classname { type instance-variable1; type instance-variable2; // ... type instance-variableN; type methodname1(parameter-list) { // body of method } type methodname2(parameter-list) { // body of method } // ... type methodnameN(parameter-list) { // body of method }}
0 comments:
Post a Comment
Let us know your responses and feedback