class & Object
class & Object

A class is a blueprint/ template for an object. A class contains data members and member methods.

An object is a unique entity that has state and behavior. An object is called an instance of the class.

To learn java programs

Data members show the characteristic /properties /physical feature of an object.The member methods display(represent) the behavior of an object. From one class many objects of the same type can be created that is why a class is called an object factory.

All the objects of the class will have state and behavior. The data member represents the state and the member methods represent the behavior of an object of a particular class.
For example in a class student, age and student name, father name can be data member and payfees() and study() can be the member methods.

From the given class any number of objects can be created. All the objects of this class will have the same state(physical features) and behavior (functionality)

The values of all the states will be different for each object. The values given to the state is called an attribute.
A real-life example of a class and an object can be a map of a house and a real house.

The map of the house gives a blueprint of the house that will be constructed using the map of the house, the house is an object of the class-map, the object is an instance of a class map.
Here class map is something that is not a real thing, it is something abstract that cant be used in real life, but when an object is created from a class, it can be used in real life.

The syntax of a java class is as follows.

class Student
 int age;
 String stud_name;
 String father_name;
 void payfees()
 void study()

The syntax to create objects from the following class is as follows.

 Student Pratikraj=new Student();
 Student Anay= new Student();

Both these objects will have data members that are mentioned in the class like age, stud_name, and father_name.
The values can be assigned to these data members in the following way.

 Anay.stud_name=" Anay";
 The functions of this class can be called by the given syntax

For videos related to java programming


Please enter your comment!
Please enter your name here