Java class concept



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.

Clas Concept in Java Programming Language

Now this is just a template , called as “Class” , and Object is instance of the class.

Objects in Java Programming

Summary : Class Concept in Java Programming (Quick Look Class)

*Reference : Here

Syntax of Class :

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
    }
}