World's most popular travel blog for travel bloggers.

Class Concept in Java

, , No Comments

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 :

  1. Name of Person
  2. Gender
  3. Skin Color
  4. 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 –

  1. Talking
  2. Walking
  3. Eating

Thus in short Class have –

  1. Class name
  2. Properties or Attributes
  3. 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