Tuesday 16 June 1992

What is a Class in Java

  • Class can declare using keyword class with class name.
  • Class is blueprint or set of instruction from which object is created.
  • Class is a collection of data members / variable and member function / method.
  • Data members/variables are nothing but variables that is declare inside the class.
  • Data member is also called as property.
  • Member function is function that can be declare inside class for specific action.
  • Whatever we can see in this world all are object.
  • All object can be categorized into special group.
  • Each group is termed as a class. 
  • For example, a programmer can create a car class which emulates a car. 
  • This class can contain the properties of a car (color, model, year, etc.) and methods (functions) that specify what the car does (drive, reverse, stop, etc.).
class className
      {
      }
 
Class car
 {
 var name;
  }



  • Some of the common characteristics of dogs are 1.breed 2.age 3.size 4.color  that can be called as data member of object.
  • Some of the common behaviors of the dogs are sleep ,sit,eat so these are called as action or method of the object.
  • Class Name :- Dogs
  • Data members or objects are :- size, age, color, breed, etc.
  • Methods are :- eat, sleep, sit etc.


Share This
Previous Post
Next Post

0 Comments: