Okay that nothing so now we understood okay what is my in class variable okay in the class variable what against or same way I said in the same same part I have whenever defining a class I have also member method or class plus member let's see party this class okay so whenever I'm saying this class members class method what so it's nothing about the behavior of the class see data members or define the state of the class okay what it contains and class method defensive behavior see Manasa Jia person with name as manners, okay. And the age is something and the gender is male and the qualities nice something okay. Now these are the state of the manners what message but how are we is it manageable, manageable, manageable lead for That is nothing but behavior, how he beers with the people, what is the, like how he walks, okay, that is a behavior.
So when it comes to the behavior that are nothing but my class method. Okay, so I'll start with the syntax of writing class method, then we'll define what we can do it, like in the calculator that he behavior, Addison Addison up to number I want to do multiplication of some number I want to do that the behavior of my calculator. So if I create a calculator, the class and the behavior, I can give addition, subtraction, multiplication, all this kind of thing. Okay, so whenever I'm coming to this syntax of the class method, what I want to do, again, I'm going to give me access specifier. AMC, I'm just writing it as an optional. access specifier.
Then I'm going to write in the access specifier. We will have the public private, but I'll talk for kind of assessors where we have and also in optional, we may have an override. Okay, We may have static and then we can define it as some kind of data type Okay, I will tell what is the third type nothing but I can say return type, then I can detain my method name, then inside the method, I can take optionally some input parameters. Okay, input parameters, then I can I can just write what this class is going to do in certain records inside this I'm going to write my logic and remember whenever I want to commit I can do this double plus or I can write the comment like this. Okay. So, now see, whenever you want to define a class he will give you an asset procedure, then you may use override or image static Then that is nothing but I can watch this week I can say it's a return type Okay, then my method name, then input parameters.
Okay let's understand what is especially going to be you tell me what kind of assets which way it can content same like it can be public it can be private, it can be no global will go as a classifier, it will not come to the method in which classes global it will by default its mobile. And also you also you can depend global also but it's always we go with our classes, you can depend on everything. Okay? So now stemmer we have over and over again we'll see on the time of inheritance, okay. So how are you feeling tell a basic example. Let me see in the real live example, in a turn.
So we are going to in In the Properties and behavior of our parents to us, so if you see, you have also some behavior inherited from your parents to you, okay? So some kind of behavior also you have your own, okay? So some kind of behavior you bring from a parent to you, and you override that with your behavior. So when you come with that kind of thing, we will do override we'll see in complete detail when you go to inheritance concept. Okay, same Oh, you have the static, which we'll discuss again in the upcoming series on how this started going to be useful for us, okay, that will come with the static part, then we will convert it and type it. So now what is the meaning of return type?
Okay, let's consider one small example. It's a very basic example of giving. Let's like you will never forget what is returned, and how I'm going to store the data and parameters. So now, let's continue you went to marriage getting married into marriage that is a full counter you have Yes. Okay. Some full counter Yup.
Okay. So like a nice delicious Indian food. So there we can go on enjoy nicely. So that is one counter we have wherever I have biryani here, okay. And here I have some drink I have here, okay, here I have some roti and some tea like this. Okay.
So now each we let's consider these are nothing but one one method for me this one one counter what we have considered use one method, for example. Okay, so now let's see, you are going to bring something. So being a person what we're going to do is we're going to call this method okay you are some other function or anywhere else. You are going to call this Okay, so whenever you want to call that means in a real real time for any real volunteer to what I say you will go to bring the DNA I'm incorrect. So he only go until the insect somebody in the counter who is orbiting you, you could go and give the DNA how in foreigners you will go with a plate okay give me a billion Am I correct? Yep.
Yes. So if you go to the drink counter, so how will go I will go like in a very any counter you want to go into the plate to a drink counter, how we will go. You will go to play all the way to class. Yes. Perfect. So now you expect whenever you will go and call this variant encounter, you will get the something from the counter in your plate.
And whenever you will, we will go to drink counter. You will get something from a drink count or in a glass You will go with a plate, if they if they are given a plate, you are not able to take it, you will display it or it will go somewhere else. Am I correct? Yes. So, return type tells Queen Emery we're going to call a particular method, how you are going to get the data Okay. Are you going to get data in a plate or are you going to data going to get data in a class?
Same way, are you going to get data in an integer or are you going to get data in your stream? Or are you going to return something from that concern in some collection or are you going to get the data in the form of some a subject, how you undo how it is it is going to return you? That depends my return time or my point in time nothing what it can be in there, the import will be Yep. So now So now let's see, if I go to my Mac is what we are writing right now. See, anytime any condition, it can stop me and you can ask me again I'm saying okay. Come here if it was a method what I can do, I can define we associate, public.
Okay? Let's see, I want to get how I want to get data here. So if somebody calls this function, let's take in my, my method name, for example. Okay, so, I'm going to pass in a parameter, I'll come to this path parameter, because if you see, I said, and my function can take some input parameters often can take some input parameters. I come to that back. When I say public art, okay, so now not in Word, I'm going to add number one plus number two, this extra vital kind of expression.
We're going to use number one number two, and when this number one number two reason happens. Is Thompson going to return something? Yes, it's going to return the result. So to integer if I'm going to sum, it is going to give me in return as an integer. So it's number one plus number two, and this integer I want to return. So not anymore.
Can I say it's an ember returning the result? If somebody calls this am I correct? So this return returning in what form is returning in the form of integer? See, that is not able to go into my return type. So public, the actual Fisher, then my return type, my method name, parameter name, we can pass here, then I can do mine. Better like this?
Is this curriculum under sort of what is it a certain type of our I'm going to do it? Yes. Okay. Now, let me save this, or is this going very basic? Are you want to deal with advanced level? Let me know.
See, we'll go over your conclusion. So if you are comfortable with this, I'll skip this Things are you are okay he will discuss in this very basic manner perfect, he will find an absolutely fine okay. Now, perfect property, I want the basics with your past utility we don't have basic here then you may write a good logic but some of us may stop also, if I write public integer, I just have it. So, you understood, I have said many people in my life who are very confused about this return type or this is return to important happen. So, just remember one thing when somebody calls this how they get data and to remember more generically, remove the sample, go play, get the beginning, go with class, get the drink, go play to go drink, you know, get it, your data will split, but I will follow some error.
Same way. If I call this my method, if I try to store in somebody's string, I learned get it. Okay. This is one small example let's just say okay, this is one class very basic classes. created. Let's see how I can execute this class.
There are many ways to do the class. For this example what I'm going to do, I am going to devote this class Okay. So now whenever I want to okay now before I have to discuss passing through this class, okay, so now no personal loan for me perfect, nothing, okay, we understood do we create a class nothing but this is my blueprint, all I can do this is my template. Now, this class doesn't have any memoria lesson on my system nothing but on my oil, so on or there is no tracking happening. So now what I can I can initialize this class or I can instantiate this class to create a real world entity or create a object which will have some number of persons then we'll see what we can do it. For instance, if you see whenever I make this billing plan, this is my Plan nothing but my class what I have.
Now, I want to insensate I want to create an object or the mode I want to create a building. So how it's going to create a building? There are many things going to happen on this part. I'm encouraged the moment you want to create a building, there is many things to be happened. So let's see, let me make this a diagram wanted to make to give you a very basic concept to be clear right now okay, very basic concept. So now on the same example, what do we got my activity plan, some plan we got here, okay.
Something something we just got a plan from one. One of our details. This is my building plan. So you have the plan. Now, you want to make one building, you want to make an apartment. So what do you do first?
You have a land, consider. You have a very good land, somewhere here. Here you have a land. Now you want to contract Building So, you have a plan you have a land then what do you do learn nothing but just consider in sell first I have one platform where I can write something okay this is your plan, what you are going to do it the thing you are going to consider building what you will do you have planned from architect you have all clearance everything ready then what is your first step to building the layout a Layer Layer that Emeryville is building Yes. So, after this what do you need to do you want to make same kind of structure in this area. So, what do you need to do first you have lot of money and you have a plan you have learned then what you will do?
So I can say a lot of money in the sense I have A lot of resources in my central server, I have my lot of memory I have defined a class. So now I want to do something. Okay, let me look at it look Yes Look, if you have any idea what do you do on this, but first we'll try to execute the plan we fail somewhere just you may trade they don't okay let let me tell you in a very, very basic level, okay. So, even I have I have one my architect, then this is my land and this is my architect plan. Then to construct it, I want to construct it simply I can say one what I'm saying are you want to construct it correct. So why I want to construct the I cannot go to work there to bring the brakes to make the walls.
I need to hire some contractors or some laborers who are going to construct it. Am I correct? It may contractor it may be never ending So who are going to control? Can I call them in more than one terminology Can I call them as constructor? method? So, there will be some constructor who may be a contractor and laborers.
Okay? Or maybe some civil engineers will maybe depending on my budget and my plan, okay so that constructors will work for me to give one billing for me I'll pay the money Okay, take this much money. And this is my plan this man make a building permit for the constructor combination of nothing but my contractor. My laborers are some civil engineers who work to make this the architect plan to be with some physical, real world, entity or real world winning your cancer. So who will make this building Simply I can say some contractor contractors, they will work to make this building. Am I correct?
Yes, yes. Anyway, so if I go to technical concept what I'm going to say here, this is my class. I'm encouraged to see, this is my idea it This is my class. Correct. So now my class going to make a notice on real while doing nothing we're going to cancel now. object.
So how this object constructor there is something called constructor. co are going to construct it. So constructor are one thing who is going to make my build my class to an object? My constructor is going to create an object for me from this class. You may have heard a turtle a word always correct. is no constructor is a thing who is going to convert main clause to object.
So now I have this plan. This plan has a constructor, same character can make the same building in some other idea occurred. This method and so now how many times you will invoke this constructor, that main intention object is going to be insensitive Okay, now what's going to happen so what is coming we'll see what is constructor in a class okay you understood in a class I have class member and member method. Now I'm going to show you see input parameters I'll talk again I'll come back to this class method how I'm going to pass input parameter I'll talk about a flow to come complete, I come to object back Okay. So now object nothing would you say real world entity I can say or I can say this is something which have some memory allocation in there to live I can say I can say that is something which has Okay, to do these, what do we have?
We have something called constructor. So we'll understand what is constructor in programming language and how it's going to help us to create in my kid object in my class, okay. So let's see what is happening. So now whenever you write a class, okay. So, constructor if you say whenever you want to create objects will invoke, call to pass if you write in a mini small program also, you know on his computer you have huge maintenance, you may miss it. Okay, so when I say constructor, what it is constructor, we can say is like a method only.
You say? special method I can say anything in work use this method. Okay class. So, the class now, let's see, if your class is seeing the customer even see, it is same as my class name, it should be something like this. Okay? It's the same name as the class name okay.
And this method See, whenever I'm writing a method I am dependent on return type. So consider the letter for each job, no return type. Let us know. Again, can can take it can take any number of parameters, just you know One more thing you have to remember always whenever you are creating a class people don't see any method as the same as last name. That means there is no constructor defined. The moment constructor is not defined in the class.
Constructor is not defined then what is open compiler going to be one default constructor Okay. That is going to be my default answer. If you see on my class I have written on calculator class there is no class name, more method name as you can see, but that means if you see in the backend what happened if I go and write in a notepad, when the compiler my class is going class is going to be set like this? It will be by default there will be something within us like this calculator. It will be something like This, okay, it will something like this My class in the system right now, if I want, I can define my constructor also. Okay, but Taylor timer don't define the constructor.
By default system supplies one zero argument constructor argument, there is no argument inside this method again, see, this is going to be like this. So whenever I'll come to how I'm going to mention this, but now, my system is like that. And whenever you want to instantiate the object of this class, same way, whenever you want to get the object of this building, well, you won't do what I said. I will call the constructor to construct it in a single line. So now Same way, if this is a class for me what my constructors I have, if I don't write a constructor in the system, what is going to happen? It is going to give one element considered by the system automatically, and for how include object or so on I will call my competitors okay.
So coordinate contractor I am going to await whenever you want to call it or nothing but I am going to allocate some memory to it simply I want to do what I want to create object of this class so my class name okay then my object name I can define, let me write my polling texture how you create the object, my class name, then my object reference name equal to make this new and my constructor name is the same as class name. You can see the class name if you understood the class name. What exactly is a constructor we are calling. Okay, if you write this statement, okay, I can simply type here my constructor name. Okay. Go into to listen for me for the jumbo calculator up Doing.
So while they do customer service or their father's name I gave CMC, it's going to happen. My new calculator. So the CLC is nothing but an object reference, wherever they're pointing to some memory memory allocated to my object created for this class. Is this clear? Or any question? You can ask me any type of question you can ask me, it may be a silly question, maybe congressperson, anything as me.
So before the is for your saying rate calculator can CLC is nothing but a custom data type that what you're seeing right before? Right now I can say since you can set it out it. Yeah. Okay. Now up, hey, go to my Developer Console. Let's see I wanted to get it.
So from the developer console, I want to debug and I came to want to do that anniversary window where I'm going to Do something without storing the information in my metadata server. So let's see, I have a class called calculator. I'm going to instantiate one object. Okay. So I gave me an object reference name that I call my constructor here. I just gave my new calculator.
Correct. So now I do calculator.in the class what I have in the class, I have a method called out, okay? I just call out here. So are not taking any parameter, you know, a woman and passing in my method. So I'm not going to pass anything from here. Okay.
So now when a call is going to return one, it's going to return an integer. So now I am going to store the result into the let's see, I end array is equal to this. So now you can go in here, I do my system to print any any statement. In a debug log. In the offense. You can write the Delta method on a system class defined method which you call system that deliver let's see I count against the artists on is nothing but what I got to return.
So nothing Are you just going to ask for video you've got in the beginning something totally want to execute if whatever you're writing on this window, if you only do two you can click into. Or if you want to do a particular line of code, simply select that you can click it highlighted, and the moment is completed completed. If you want to see the log, see like this open log, you can so on in this Developer Console, you can see everything when Memorial overtired Guatemala Alligator, or so all the users can see line by nine in the log file. So I clicked open log and click into good. So the code is going to instantiate the object of this class. Nothing we're allocating the memory to it.
Then invoking the method so whenever you have non static See, I say static, which we'll discuss in upcoming systems. So EPC in this class, there is nothing to defend static keywords. So, all of my non static are instance variables are instance methods to assess any instance members or instance methods, I can assert using the object name.my method name or object name.my variable name whatever you want. So, now, I want to access on this class my method, so, Id the instance name dot method name if you see this this is going to be this one I just call this method name by invoking my object name.my instance method name then I click on execute right now, here the moment a default Something happened in the system might mantronix on any sector and I got the return from that method if you see I got it slow. So, if you see the log you will see this log how much memory Oliver he follows assumes everything you see here then you will see the debug logs I mean if you want to see only my debug log for to have written in place like this one he will only he will see here you can see the artist happy.
So now my logic is going to be telling the system what we have written and return me the result. If you see here, I got metadata plus multiple copy. Any question in the construct? You know? Any question matters. Yes, I have one question when exactly we need this constructor in our ethics class.
Okay, see right now on me after class. I didn't write my constructor. No worries. It's okay. So let's see. Here I'm setting 10 and 20.
That is one variable. You can you can see depends on the logic what you're writing, okay? So whenever you want to initialize something, okay, I'll just go into that part. Okay. Go anywhere you want to initialize something, dueling object, create Okay, so that thing we can pass in constructor. Okay, that means what do what does it mean?
So let's see here 1020 I want Okay, let's, let's see, whoever created object they will pass what is the value of number one number two, so I am not going to initialize anything here. Number one, number two, I don't initialize. Okay, so what I'll do here, I will write a constructor constructor is same as class name without a return type. My class name is capital. CMA wrote one method without a return type. And now I have passing the constructor with two parameter one I can we can say integer number one and y one I can say, lets me is going to go to point here, okay, I can pass in an integer B, okay.
And simply the value what I'm passing, I can set number one equal to here, and I can say number two equal to b Yeah. So see, then I cannot say nothing good I can say the moment you are going to instantiate the object, I am passing some value and initializing it. So now, if I go to my previous solution what I did here, okay if I try to execute here, see there is no concert are different because I have written one constructor with two parameter passed. So, system not going to provide any default constructor for me, which will be now my governor expect to get there. So I pass it on 72. And the moment I passed it and 78 during my object creation, I initially I initialize the value to data members, and then I call my method with recorded so I click Execute.
So, let me go here. Sorry, I have to, I have to pass it here. Okay. 30 and 70. Okay, now this doesn't have anything I pass the value here. Now it does play a key role.
Okay, now you can see the debug log 30 7100 correct. So whenever you want to initialize something during the object creation, you can write your own constructor and you can initialize it whatever you want. That's the one basic fundamentals. Okay, now this is clear or in question menaced. No, it's clear. Perfect.
Now see, it See I writing integer A and B number one, it could be a number two could be this is not two looks good. Good. Yes. Okay. So now I'm going to introduce one thing, this is something called this keyword okay. So okay, we understood, we see this referred to what I have written I can write another I can have multiple control.
Let me see. I can write one more concept also. See, I can have multiple consider also noise. Okay, integer interview. Let's see. I want to do Do some double value, I can do double a double B also, I can pass double A and double B also.
And also I can give me one more variable like key, then I can call in the number one into the realm, it needs to be this total or double value. Okay, I can also write another constructor for the same way with anything. So I'm saying I can do any parameterised change. And I can write multiple constructors also. I can also say with this one part, whatever you want, we can do it on this one. I just did it successfully.
I can sit. Okay. So that means you can have multiple constructors with the different parameters. I cannot write with the same if I try to write the same letter once again with the same parameters. Let's say I'm just going to write once again. I tried to say it's not alone method already defined.
So it's saying we unharmed dependent costs are nothing but it's the concept of method overloading. Okay? I'll come to the third one second also, but cosseted also can be overloaded with different parameters, integer A and B i can depend who will be or integer a there will be any combination you can do it will not be match, it will be different match, then we can define multiple constructor here. Okay. Okay, so now what's going to happen? Let's see, here, I pass my integer a, an integer B, I do idea.
Let's consider, instead of that, I just do the integer number one and integer number the number two here. Okay, so now if the same name I have if I try to do number one equal to number one, and like number one, we did before number two equal to number two, then switch number one I'm going to defer Is this the last variable or these these classes the class variable or the this the method variable which when I referee. So, compiler winner will be confused what to say it may said to this number one and this number one may have empty values which I'm a senior allow to do whenever you want to assess anything from this class okay see what I can do I can say this does one basic example. So, these are the multiple uses this is one this I can see I can say this DOT number one and call number one that means, on this class test this number one variable and set the value to this method variables this DOT number two number two also.
So, this keyword what we can do like we cannot define multiple variables like also we will see these examples whenever we come to the inheritance concepts okay. For now we see this as you can pull whenever you want to access the class variable name inside a method. You can also use the this keyword okay. This is very basic. Yes tell me. Could you please say one more time this indeed Okay see these nothing word eg key word for me.
Okay. So these let me make a note they will understand it okay object object creation you understood? Yeah. Now I'm coming to this code because I'm in that example. So, I just shown you that is, so this is a keyword which can be used. Let me note it can be used to a rapper instance variable of the class instance variable of the current class insert variables which variables or data data members ID declare with static or no static declare some that we call as instance variable.
Okay, so whenever you want to access the instance variable when you want to refer the instant not if it's when you want to report the instant variable we can use make this okay? So this this can be used can be used to invoke initiate okay. Okay there are multiple things we we saw only the password password okay? And also can be used or the three can be passed argument in the paper we'll see everything one by one okay and also can be written down. Somebody might simply we saw these can use to any instance variable of the current class That means you can see if I want to refer my number one though See, I have number one or two variable it also our number one variable, you are the number of variables. So same name, but I want to refer my class variable i want to assign the value to my class variable, what value I got from here.
But like before I did number one equal to a, it was like the skirt. Yes. And also again, I had number two equal to b and that time, my parameter was like this integer a and integer B occurred. So the time Okay, the method variable into my number one class variable, and be my method variable assigned to number two class variable. My name is Sam. Number one equals number one component on this variable is not going to do anything.
So what I can do, I want to refer my class instantly So, he was number one. So, simply I can use this.my class variable name equal to another variable we have cinema this.my class variable name equal to the method variable name what we have here, this is one point so it can be used to refer to the instance variable or current class. It can be used to invoke current class constructor is imply can do in this class in Premiere I can do this calculator I can call also I'll come to that but don't be will not go to that that expert level now let's understand basics okay. So passport This is a very basic so we should understand. So whenever you want to refer any instance it will simply we can use this dot variable name. Okay.
Yes, yes. Perfect. So we understood this nothing. Let's see. I don't want to as as a woman, let's I will pass that Click on make class. Okay, I don't want to define any classical and costume elements.
Okay, I just going to comment out, we should consider your costume concept. Like, I am just going to comment everything. So what I do here, I don't want to declare anybody will also. Okay, I'm going to pass arguments to my method. Let's see, I passed my integer number one, I pass my integer number two, and I get my employee I'm going to pass as a parameter, because I said, my method can take parameter input. Perfect.
Now what I'm going to do here though, this is my class I defined, let's see, whenever I'm seeing digit number number two, and to call that method, I understood I have to create the object. And I said I don't want to pass an element in a default constructor I have that I have commented everything. Okay, I don't have any constructor only I have this method. So now to do this, what I need to do, I am going to pass data on my dad methods. So, simply I can pass the value to a method like this you may directly harbor the value here or you may have data like integer let's see in one equals 10 you can give any name integer into equal to 70 then it can pass and one on intro is no going to be same type of that a pot I have defined in method you see, integer number integer datatype located in the method parameters, so, similarity whatever I have defined here, it should be the same then I can pass it here.
So, like this also you can pass them as a parameter, it can be integer integer it can be string integer it can be any combinations it can be colored son it can be a subject, it can be object anything, any kind of data we can pass as a parameter also clear. Yes, to be seen see the output after after my activism is 70 plus Then I forget 80 Okay. So, in the tradition we understood what is a plus what is my data member, how I can tell what is my member methods and how I can create an object and using object how I can assess my methods okay. So, if I summarize it is completely So, can I can I also can I say we understood in the today's session, okay. So, how to write a class insert the class how can I create that a member and insert and insert the class how I can create my member method or template I can say constants and then we understood the concept of constructor and how I can create an object from a class and how we can invoke method from eating object Class methods how we came up with this.
Can I say we understood how or right? So, n equals e do you have this? This is not now but could you please sell this video? Yes, yes. Yes, tomorrow, tomorrow, bye. Okay.
We have one time completely you learn it again, we'll meet in the Saturday. Okay, we'll continue from here again and before to that he will get these things done. Okay. So, you please go there and go for just you want to see the anonymous window code? Yeah, I'm just coming here. I just came here controlling.
You are creating the club and Okay, got it. Setting up object objects and calling the constructor to create the object. Then I call my method. I like the parameters. Okay, so I have one small question devices. If so just if I don't do anything all those things just faded calculator dot add of 10 comma 25 posse, then also.
Yes. So instead of for writing here, you can pass integer value, it's 10 and 20 or integer value six, because my parameter my method takes a two integer value, pass it into it, no worries. It can be the number one number not about replacing this 10 Tony's being replaced with that value is correct. I wrote the book only you can get it Okay. Okay.