 Professor from Department of Electronics from World Gen Institute of Technology, Sulapur. So today I am here to have a session on class and objects. After the end of this session student will be able to define class and objects and create class and object. Let us start with introduction to class and objects. What is class? Class is a template or blueprint for objects and object is an instance of class. So as you have the blueprint of your flat, similarly class is nothing but it is a template or a blueprint of what objects it has. And the individual objects are created, they inherit all the variables and methods from the classes. So for example, there is a class and there is an object. The name of the class is fruit and name of the objects are apple, banana and mango. As you can see fruit is nothing but the blueprint of the objects. So it just gives you the in general classification of what type of fruits it has. So fruit is an in general classification and the objects are nothing but the apple, banana and mango which are the members of the fruits, so which are the classification of fruits. So they inherit all the variables and methods from the class fruit. What are objects? Object is an entity that has state and behavior. For example, take as a dog and a cat to illustrate a dog has state like age, color and name and behaviors are sleeping, eating and running. So age, color and name are the states of dog whereas the behavior tells you what it does like eating, sleeping or running. So state tells you how the object looks or the appearance of the dog. So what is the age of the dog, what is the color, what is the name of the dog, it is nothing but the appearance. So how the dog looks or what properties does it has and the behavior tells you what the dog does, what it does, how it behaves like eating, sleeping and running. How to create class and object? To create a class use the keyword class. To create an object specify the class name, you need to specify first to which class does it belongs and then followed by the object name. So which object name you are going to create, you should be followed after the class name and use the keyword new. So new keyword should be used. Let us have an example, public class, main is the class name. So public class is the class name is main. So you have an integer x equal to 5, you are creating a variable of integer data type storing value 5. This is the main function you are calling public static void main. Now you are going to create object, name of the object is myobj, myobj is nothing but the object name. So how you create the object, it should be the first the class name. So main is the class name. So you can see here is the class name main. So main is the class name followed by the object name as per the definition, myobj is nothing but the object name we are going to use and the new keyword equal to the keyword new and again to which class it belongs is that the main class. So this is how you create the object. Now you have created the object, print the value of x by the object. How you print it, system.out.println, myobj is nothing but the object name. So myobj.x, so you access the x variable by using the dot operator. So myobj is nothing but the object name.x. So if you run this code, you get the output as 5 which is the value of x. You can also create multiple objects in the same function. Same thing you follow it, public class, main is the class name, int x equal to 5, int y equal to 100. So you are creating the two integers x equal to 5 and y equal to 10. So main function, public static void main. Now you are creating the two objects, myobj and myobj2. So main is the class name followed by the object name equal to new is the keyword and the class name which is main. Same thing you are doing for the second object, main, myobj2 equal to new keyword and the main. So you have created two objects, obj and obj2. Let's print the two variables using the two objects, system.out.println, myobj.x you are calling the first object using the variable x, second system.out.println, myobj2, second object you are using to call y variable. So myobj2.y. So if you run this code, you get the values 5 and 10. So here you have created two objects and you have printed the two variable values as 5 and 10. Now let us try, write a program to print id and name of the student. Open the command prompt, open the editor, notepad, create a class, public class and you are creating as student class name. We are going to store the student id and student name. So we will be requiring two variables for roll number integer data type and for name string data type. So int id string name, call the class now, student test, call the main function, public, static, void, main, string, ar, create object s1. So student is the class name, create an object s1 equal to keyword new followed by the class name that is student bracket complete. So you have created an object s1 with the class name as student. Now assign the value s1.id equal to 101 s1.name equal to in the codes sonia. Now just print, so just print system.out.println s1.id plus s1.name, you are going to print both the values s1id and s1name. These are the objects you have created s1. So you are calling the two variables s1.id s1.name. Just complete the bracket, save the file using student test.java, open the command prompt, call the java compiler java c student test.java. The code is successfully generated the byte code java student test. So you can print 101 sonia which is nothing but the id and the name of the student. In such a way you have printed id and name of the student. Think and write, what is the size of the class? Pause the video and answer the question. If you are not able to answer the question, rewind my video and try to rethink and answer the question. The answer is classes does not have any size. Actually the size of the object of the class can define the size. So there is no size for the class, size of the object of the class can be defined. References are written from java, a beginners guide, core java 2, volume 1 fundamentals, java 2 the complete reference guide. Thank you.