great so I start great morning so yesterday uh we have started with a concept known as inheritance great so why the strength is looking great today since I told inheritance is a primary concept why we have to go and attend the primary classes right okay so inheritance we have started and we understood what is the definition of inheritance what is the definition of inheritance it is a prop process of acquiring the properties and behavior from one class to another and we understood what are the advantages of inheritance we have three advantages number one code reusability number two time and effort will definitely reduces because you reusing the code number three so profitability of the company will definitely increase good so we have started with the inheritance now we'll understand what is the definition of the inheritance properly using my code now what is that I was telling you that there's something known as acquiring the properties and behavior we have two beautiful words there properties and behavior my question to you is what do you mean by properties what do you mean by Behavior long way back this properties you have learned behavor you have learned correct ah where you have learned object orientation principles of object orientation there you have learned it you took this object object is a fashionable way so that is why I'm showing this way anyhow so this object is having two paths your previous trainer told what is that so has part or else you can as what State or properties very good what about this Behavior so in Layman terminology State and properties I tell it as has Behavior I tell it as what does like this how you will code your Properties or haspot using data types good and what about Behavior using methods so what it is trying to tell is properties means data types data types means what variables like this Behavior Behavior means does does means what methods so what is trying to tell is the variables and methods from one class it is getting acquired to another class that's the meaning of that now let us see what it is so we have one class the name of the class I will tell it as demo one like this inside this demo one class we have the variables as well as we have methods like this we have that inside a class I will create one more class like this the name of the class I will tell it as demo 2 now the definition of inheritance tells that acquiring the properties and behavior from one class to another in one class we have already the properties as well as Behavior getting it from one class to another class is inheritance but now the question is how this class can get variables and methods properties and behavior from this class how can you get it if you have to get it Java told that you have to use one keyword and that keyword is what extens you should tell how should I tell sir demo to wants the properties and behavior of whom demo one you should tell demo to extends demo one like this when you do that all these variables and methods the properties and behavior from this class will reach to demo to understanding very good now what's this so before I code my first program my friends let us understand civil engineering how many of you civil engineers here no one okay no problem problem what's this I want to build one home now this is my home and I want to build it to build this home this is not how home looks like I'll create one home in this fashion and this is how it looks like good so many things are there inside this maybe one living room one kitchen two bedrooms very very important one toilet like this many things you have it good a swimming pool also you have everything now tell me my friends before you build that home what you'll build uh so what you will do is you'll go to one civil architect you'll go to an architect now architect what he will do he will plan he will design that okay your living room should be here your kitchen should be here your bedroom should be here your another bedroom room should be here your swimming pool should be here like this he will put a design and now looking at this design the house is built correct in the same way if you are coming to a software engineering as well this is our software engineering before you build any program or application first you have to design that application now the question is how can I design it how you have designed it with the help of a diagram yes or no in the same way before you build that web application or a program or a software first you have to build the design in the form of a diagram what are you trying to tell sir what's this who is he demo one who is he he's a class first before you create that class you have to get the design of that class how I should represent that class sir you have to represent that class in the form of a rectangular shape like this and what is the name of him demo one so you should give the name as demo one whenever you see the rectangular shape who is he he's a class very good who is he he's also a class class means again you have to tell something using rectangular shape like this and now you have to give a name for it what is the name demo to like this very good look at this demo two what is's doing he's extending demo one extends also I should tell it in the diagram correct how should I tell it you should tell here one thick line like this and there should be an angular bracket above like this which will create one Arrow like this meaning of this is demo two is extending demo one demo2 is getting the properties and behavior from this class to this class first you have to build this looking at this you have to build your software understanding and whatever the diagram you built here this I technically call it as U ml diagram what diagram uml so what is this uml uml is a short form of a full form what is that full form unified modeling language that is like a civil architect building a design for your home in the same way as technical architect civil architect will not come here then who is that sir technical architect will build this design he will take this design give it to the software Engineers software developers software developers will look at this design and they will create a software understanding very good now what's this what I want to do now is before I code any application from now onwards first I'll build that diagram looking at the diagram I'll create a program okay sir how you will do it what's this I want one class class means rectangular shape I'll give one name of the class as demo one I'll come here I will tell the name of the class as demo 2 like this and demo 2 want the content of demo one like this good inside demo one I want to create something before that see whatever the class you see here above that class is technically known as parent class which class parent class it is also known as super class it is also known as Base Class like this good like that the demo to what you see here this we tell it as child class it is also known as subclass it is also known as what derived class all of these are the different names what that guy is having very good so what I will do is instead of me giving the name as demo one and demo two see as a class you can give whatever the name you want but instead of me giving demo one and demo two I'll change the names of these what is that sir what's this instead of demo one instead of demo 2 like this I will give the name of the classes like this what is the name sir parent and after that child like this these are the two classes I'm having now inside the parent what I will do I will give variables and after that the methods and variables and methods I'll put a line there so that I can understand properly what I will do is parent will be having certain height like this and this height is a float type that is what I'm showing you the parent is having certain behavior that behavior I'm telling it like this parent will always read books this is the behavior what parent is having very good so this is how my uml diagram looks like now let us see how can I code this uml diagram in my Eclipse now let us start that is my diagram I have to code it for that I have to go to my Eclipse my eclipse is here good he's ready now I should start building my S software the most important thing is among these classes which one I should code first very simple you have to go from top to bottom top is this you're coming here whom you're finding parent first you have to create that how should I create sir who is he he's a rectangular shape rectangular shape means what class like this I'll give the name of the class as what parent in this fashion very good what variable is having height so that height I will tell it as float float what sir height parent is having certain height maybe that height I'll give it as 5.8 F like this this is not the only variable you have what the behavior as well that also I should give it what is the behavior there read books behavior is nothing but your methods correct I will create read books like this and your parent will always tell that reading books is good for the mind mind for your health and for your success as well so parent will always tell I will read read what books like this that is what the parent is telling he's not returning anything so now I'll give the return t as what why you can see there there a semicolon missing good you can see a class is having a property as well as Behavior so now parent class is ready what I should quote child come here I'll create one class the name of the class I'll tell it as child look at the child what he doing when Arrow Mark going up means what extends very good I'll come here and I will tell it as extends like this extends what sir parent parent is here in this fashion now tell me inside the child what you have to your Naked Eyes you are feeling like inside the child you don't have anything but actually speaking inside the child you have something what I'm having sir what you told extense parent what parent is having height what parent is having read books both of them will come and set now let us see even though I'm not giving anything there height and read books is there inside the child or you want to see it then go to the main method main method is here what should I do now I want to access the content of the child what you will do child is a class class is imaginary what is real object you have to create an object of this class how you will do I'll tell to my jvm jvm there's one guy whose name is chai looking at him you please create an object for this object I've given the reference as C and I've given it as child Ty now I will take this reference C and I want to access the height of the child now I will tell C C do what height like this I want to print that value print that value cut him put him inside the print statement like this good height is done after this I want to see if child is also having the behavior also or what what is the behavior read books I want to access that method also which is there in the child let us see now I'll come here I'll see dot dot what sir read books like this now think and tell me when you're accessing the height using c c means what child look at the child do you have anything there maybe to your naked eye nothing is there put Java goggles and Z you'll see something what is that height read books it is coming from where parent because that is what you told them understanding very good if in case I save it and execute it you can see even the child height is also 5 .8 and child is also telling I will definitely read books now tell me parents height is some 5.8 what will be the child's height approximately same only right parent 5.8 child 6.4 some serious problem is there but what I'm trying to tell you is parent what is having in Java child is going to have the same thing understanding well good now let me code my next program what is that before I code it I have to get my uml diagram but before that tell me what is this what is height properties what is read books Behavior properties and behavior from one class you're acquiring to another class this is nothing but your inheritance understanding very good now let me go deeper inside this now what is that inside the parent it is not only the height you will be having something known as color parent will be having certain color not only that parent will be having the most important thing and that Indian Society always focus on what is that nose structure yes I don't know you guys have encountered this or what I have encountered this many many times and if I have to give one example example in my home you know there is my cousin so cousin is getting married he's married at this point of time but previously some two years before he's like shage come with me I was like why I am getting married means I have to go and see a girl I was like hey you are getting married you should see a girl well I should come he's like no no no so this is the first time I'm seeing a girl I mean looking at a girl to get married so I'm scared and I was looking at him what I will do huh what I will do then he's like no no no you have to be with me I was like okay I'll come his parents his relatives went to that girl's home I also went girl home girl parents welcomed with a red carpet please come please come like that we went living room there is a big sofa there we all sat and there's a chair in the middle I was thinking this sofa is beautifully arranged at the corner of the walls but why this chair is in the middle I was thinking but suddenly from one room girl walked how she walked like this she walked like this because see you cannot take your head and you know see like this because what the people will think right she came the chair it is meant for her to sit she was sitting like this how like this she are sit and now all the people surrounding her is looking at her how much awkward she will feel but what to do this is the so-called Society of this country that is India now this guy my cousin you know is telling like this I mean I mean a friend my cousin you are going to marry that girl I'm not going to married huh so it is you who should look at the girl you look at it so she's looking at I mean he's looking at that girl and he's like hey she's damn beautiful even I want to speak with her if everything goes fine you know she is my soulmate in the next coming days that is what he told okay you are going to marry her you decide after some time she went inside he also went inside to a balcony and they spoke he was like come with me come with me I mean what should I do my friends you only tell me man you are going to get married I'm here just for you I'm going to sit they're going to give some food for food I'm waiting okay I will have the great foot and I will go with you that's it I am nothing to do with your marriage nothing then after some he was like okay he went to the balcony spoke with that girl for 15 minutes what he spoke God knows but he came back then he's like yes she's damn good she's intelligent she's humble she's IQ is great I'm going to marry her I was like okay you're going to marry yes after some time poha came poha poha you understand poha in Canada we call it a AAL key so on that there is some shave as well after that at the circumference of the plate you know I found darad paa also you know darad paa so you want it because I belong to that place you know you want Dar paa give me money okay I will get it so darad paa is also there so paa I had iy I had I got some tea as well so tea also I drunk and we went to the home and when we went to the home the discussion is going on so how is the family family is good how is their home everything they will look right how is the home home is good how is the character of the girl boy told he very way awesome awesome after this there is one lady okay relative far far related of my cousin she is like hey everything is great family family the parents character of a girl the way the girl looks like is amazing but only one thing is missing nose you know nose is actually not what we are expecting it should be like a Greek god you know Greek god it should be straight you have seen ruik Ran's nose like that it should be I was feeling like I should get up I should go to that wall and bang my heart like this that is what I felt I mean you are in 20 I mean 21st century and this is how you're thinking about a girl and you are thinking about a human being and this is the irony of so-called Indian Society you're laughing in the next coming days this is what you're going to experience because you are also Indians you know okay anyhow so no structure is also there like that a parent is having many many properties now what I will do is in the parent there is a height not only height there is color as well string color like this so within double coats so he's an Indian I'll just tell it as brown color like this see again I'm putting a disclaimer all these examples is for your understanding purpose in a much funnier way of understanding it why I'm putting this disclaimers again again and again what happened is in 2020 during the corona time time I was taking classes online online classes I was taking in the studio I was in a different organization working before what happened is I give the same example okay I told that height you know height is 5.7 if the parent is having the height 5.7 child will also get the same if it is not the case there is a big problem is there I told you right this guy you know a guy from Kerala was my student he was attending the classes online back then because Corona time actually his parents were shorter okay but he was taller he related with that and he was like oh sir is telling to me only what the hell man see I haven't seen your parents I haven't seen you you know physically and how can I relate to you has literally texted me in the zoom in the in the zoom chat I ignored that he put a message in the LinkedIn telling that sir you told to me only sir I told him my friend it's not like that just for an example I took it now again he continuously messaging and he is like you know giving lot of frustration to me then I just you know stopped uh you know telling him and convincing him it is not like that after some time he literally during Corona time from Kerala he came to Bangalore to meet me that what sir you are telling like this sir I was was like it's not like that my friend there is one restaurant here we'll go there I gave some coffee to him and after that he was okay okay sir I got it then I told him go back to Kerala now but again so all of this don't take it seriously take this as an example to understand the concept in a much better way good so now what I will do is I'll give the color there after this color I want to give the no structure as well well string nose structure like this good so within double quotes I have to give something so I'll just give it as normal okay no comments on this normal I will give okay so this is all the properties of a parent now I have to give the behavior also what is the behavior read books the parent will read books it's not only that parent will not smoke as well that is the behavior of the parent now parent is like hey he's telling to the world that look I'm not going to smoke he's telling I will not smoke like this the return type I will give it as what what this is one of the behavior of the parent in the same way he's telling something as well I will not have this also what is that sir let me show you void no no what drink like this drink drinking of alcohol is what he's trying to tell so system. out. printen he will tell I will not not what drink like this drink good so this is how the parent is okay how should be the child same right same good so this is parent and this is the child and I don't know in the real world in the real world it changes but for job what a parent is having that is what the child is having but what to do in the real life this is exactly the opposite the parent the parent is so great you know he's like Shri ramachandra he's like I will read books when he get UPS you know he'll always do some workout he will exercise he will read books he'll have a great breakfast and he'll do his work at the same time child what he will do wake ups with mobile like this and after that doing what having the breakfast with what mobile like this read books means nothing doing that is how it is and now in the home at least he's doing like this when he comes out of the home you know he will show his rudra what is that start to smoke start to drink and all of that is there you cannot do that my dear students because you have to respect your wonderful parents there as a teacher I'll just give you a suggestion for you there are so many things which can give you a kick many things are there in this world which will give you a kick kick is what people expect right you have to travel you have to ride a bike you have to go for swimming you have to do gyming you have to play cricket they'll read books lot of books do sketching do painting with this you'll get the same drug effect the same Morphin effect the same dopam man effect but what to do the many people will choose the other options to you get that Morphin dopamine and that kick but as a teacher it's your life nothing to do with your life I'll just come here for 6 months I'll be you know coming on the stage and speaking with you but after sometime I'll disappear but as a teacher I have to give some suggestions never ever go into this if you're literally doing it at this point of time stop doing it but at this point of time it's your life what you want you can do anyhow now tell me what child child is extending parent parent means the properties and the behavior from the parent who will get the child will get let us see is he really gets a what he's getting the height what parent is having next one color let us see is this child will also get color as well I will tell C dot C do what sir color like this not only this let us see that will this child will get that NOS structure as well like the parents 100% he getting it's not only that read books is one behavior of a parent child is getting it there's one more Behavior what is that sir no smoke that is one of the behavior child will also get it not only this there's one more Behavior which the child will get it that is what no drink you can see there in the child nothing is there but actually speaking many many things are there which is invisible for you and what all things are whatever a parent is having everything child will get it and you need the proof the proof is here now let me save it and execute it when you do that you can see there even child is also telling this way my height is like parent my color is like parent I am having a normal no structure my parent read books I'm also reading books my parent will not smoke I'm not smoking my parent will not drink even I will also not drink understanding very good this is the definition of your inheritance but I told you the advantages of inheritance as well what are the advantages code reusability tell me have you coded your program yes you can see this code are you using it here yes you're not coding it once again see you are using it what is this code reusability now tell me have I spend some time and my effort to code this no time and effort has reduced right I haven't coded this because of this the profit of the company will also increase got this great so slowly you guys understood what do you mean by inheritance now with this we are going to go for the next concept the name of the concept is types of inheritance we have to see now and this is my Brand New Concept what are the types of inheritance sir number one it is single level inheritance number two multi-level inheritance very good number three this is hierarchical inheritance hierarchical inheritance like that you have Hybrid inheritance like this you have multiple inheritance like this you have cyclic inheritance as well so these are the types of inheritances and now we have to see one by one to start with we have to go for the first one who is that single level inheritance so before I code it let us see how it will look like in the real world in the real world it is there in Java also it is there what is that sir watch it there is a mother mother means I will tell it as the parent now to this mother there is one child and I will tell it as child tell me can a single mother can have a single child is that possible yes why it is not possible it is possible in the real world in Java also it is possible no problem at all in the same way if after to convert this real world into Java I have to put a diagram first to start with uml diagram he is a class the name of the class is parent I'll come here I'll create one class the name of the class is what child and child is extending the parent like this so what I will do in the parent I will give one property here the property is height I'll give the behavior here the behavior is read books this is what I'm giving now let us see will this work or not and what you seeing here this only we call it as what single level inheritance and what is the meaning of this there is one parent one child one child is acquiring all the properties and behavior from one parent this is single level inheritance let us see is this really the case of what or will it work or not what's this I'm having a parent class parent it is having only height no color no no no structure I'll just eliminate it is having read books as well only read books I will tell it in this fashion you can see that is my parent class this is how my parent class is looking like in the software good now next what you should code child child what is doing extending whom parent what you get here whatever parent is having what parent is having height what parent is having read books both of this he will get it now let us see is this really the case or what yes you can see there I'm accessing the height and I'm accessing the read books also you can see this is how my output is looking like you know this already but this kind of a inheritance specifically it is known as what single level inheritance one child one parent understanding very good with this we are going for the next one because the first one is done and dust next one is what M multi level what is this multi level what's this friends see this is how it is present at this point of time in the real world forget about Java now child is having a parent his parent is having his parent yes or no great for a child this parent is who grandparent allow deny okay great you can see there my friends we have a grandparent this is how it looks like you can see grandparent who is grandparent the parent of the parent for you who is the parent of parent grandparent yes or no so tell me child is inheriting from the parent and parent is inheriting from the grandparent is this possible in real world yes it is possible I'm having my parent my parent is having their parent for me it is grandparent for you also it is the same case means in real world it is there in Java is it there yes because what is happening there is we have a child child is having the parent but that is not the end we have one more class here like this one more class and this class I will tell him as there's no space here here only I will tell what is that grandparent like this so what I will do instead of height putting it here I'll put height here instead of read books putting it in the parent I will put it here like this awesome now tell me what parents should do now [Music] parent should inherit from grandparent means he will extend like this now you can see child is getting inherited from parent parent is getting inherited from grandparent how many levels are there here so you can see there more than two levels are there so this we tell it as what multi so that is why it is known as multi-level inheritors now let us see will this work in Java also or what programmatically let us see now so this is the diagram okay let me code it here first I have to code the grandparent above parent I will come you can see I'll create one class the name of the class is what grandparent like this what grandparent is having height and read books height and read books parent is actually getting it from the grandparents that is why I'm putting it here good now you can see my friends grandparent what is having height what is having read books comeb down who is that parent class parent look at that Arrow Mark what is the arrow Mark extents you should come here and tell it as extents extends what grandparent like this now tell me inside parent what do you have is it empty no whatever grandparent is having that is what a parent is having what grandparent is having height and read books height read book books he will get it after parent what you should code child have you coded it yes What Child is doing extending extending whom parent there now tell me inside child what you will get whatever a parent is having what parent is having height and read books the same height and read books from grandparent it will come to the parent from parent it will come to the child also understanding great now let us see is this really the case or what so for that I want to see is that height and read books is coming to the child or what I want to access the content of the child for that what you should do create an object of child I did it inside this what do you have height height I'm accessing inside this what do you have read books read books I'm accessing have you given height and read books here no where you have given grandparent from there it is reaching the child understand understanding good now let us save this and execute you can see you're getting the output and whatever you're seeing there that we call it as what multi-level inheritance understanding very good with this let me proceed further what is that now multi- level is completed we are going for the next one now it is known as what hierarchical you can tell hierarchical you can tell what you want you can tell but you have to understand the concept what is this before I quote this in Java let us see in the real world can you see this kind of inheritance or what let us see now there is one parent one parent is there mother parent good now this parent will give birth to first child give birth to second child give birth to third child like this now tell me this child is coming from which mother that mother means he is inheriting from this mother in the same way inheriting in the same way inheriting now tell me one mother for that mother multiple children is that possible yes or no it is possible and that to India lot of things is possible literally you know I think in the cities in the urban areas this kind of a thing is very less they'll think about Family Planning they will do oh two sufficient one sufficient they'll think about it but when you go to Village you know see education is very very important if I have to give my own example itself my father father is having Brothers and sisters do you know how many brothers and sisters my parent that is my father is having 10 means including my father there are totally 10 means my grandma my grandparent is having 10 Sons and Daughters including six were Sons four are daughters and my dad is the fourth one like that for you also example is there yes or no more than 10 anyone no okay great this is how it is good in the real world is it there yes in Java also it is there and this kind of inheritance I tell it as what hierarchical inheritance or hierarchical inheritance like this you can pronounce it understanding great now I want to put the same thing in Java now for that uml diagram I'm having a class this is the class I'll create one more class I'll create one more class I will create one more class here there's no space I'll just push it here good one more class good who is this above class the name of him is parent like this now this parent will be having certain height and will'll be having certain Behavior also and now this guy is child one child one like that child two like that child three and this parent can have multiple children absolutely no problem this child one extending the parent child two extending the parent child three is extending the parent like this and now what child one will get height and read books height and read books height and read books that is how it is this is hierarchical inheritance let us say is this really the the case of what using my program it's taking a lot of space so now let me reduce the size of him good I'll take him and put him at one corner of my screen good watch it so first and foremost thing what you should code parent good I'll code my parent where is parents sir parent is here you can see class parent what parent is having prop properties properties and behavior that is nothing but the height and the read books is that good after that what you should code see already I've told you from top to bottom you should come top paril you have created bottom you should come now child one child two child three three three classes are there which one I should code first you can code whichever you want because all of them are in the same line same hierarchy which which one you want you can code it but there's something known as a discipline you have to follow it start from left to right so that is a good way of programming but if you're coding child three first child 2 second child one will it not work it will work but discipline is very important from left to right we will go understanding good now we have the child there the name of that child is what child one like this and What Child one is doing extending the parent and that is what I did in the same way let me proceed to the next one tell me who is the next one child two I'll copy this I'll come here I'll paste it child two what is doing extending the pale let us go for the next one who is the next one child three child three is extending the parent like this now tell me inside child one what do you have height read books inside child two height read books inside child three height read books books because you have extended the same parent that is why good now let it make it work how to make it work very simple I want to access the content of child one access the content of child two child three all of them what you have created is classes want to access the content create all these objects and access it that's it okay sir how you will do it first and foremost thing child one object I will create I have created like this I'll not stop here this I'll just push it down good I'll come here I will take the same line I'll copy I'll paste it which object is ready child one object is ready correct for him I'll give the reference what is the reference C1 like this I want to create next object also who is the next object child two I'll give the reference for him child to what is the reference C2 in the same way I have to create the object of child three as well come here child three object give the reference reference is child three give I mean type as child three reference is what C3 like that but now three objects are ready so for these objects you have given the reference also the reference is C1 for him C2 for him and C3 for him also now I want to access the content of child one what you will do very good this is what I'm doing what I will do is I want to access the height of the child one C1 do height I want to access the read books of child one C1 do read books like this is there any doubt any doubt anyone is having no quite a easy one now let me come down I want to do the same thing for child to also what I should do copy the same instructions like this paste it here this is for child two you should at a c to 2 this is for Child 2 you should tell it as C2 I want to repeat the same thing for Child 3 as well child 3 means C3 child 3's height child 3's read books I'm accessing you can see three classes three objects I'm accessing the content of child one accessing the content of child two accessing the content of child three any difficulty any difficulty no quite a easy one I will save this I will execute when I do that you can see the output for the first one 5.8 I will read books it is for whom child one next one child two next one child three you can see here or the content of the parent is getting inherited to all the children out there understanding very good is there any doubt No Doubt with this we are done and dusted with this one good with this we are going for the next one what is that Hybrid inheritance now the question is what is this Hybrid inheritance is all about what's this okay there is a word known as hybrid what is the meaning of hybrid first of all it is there in Java we will see is it there in the world we will see first if it is there here in Java also it is there what what do you mean by hybrid hybrid hybrid okay I don't know you know this or what let me give an example I'm having two children two children I'm having one child name is Kia one more child name is Maxi my dogs my two children are there Kia and Maxi Okay so Kia is labador it is not there here in Bangalore my hometown darad one is Labrador that is Kia and it's not the car it is a dog name one more is Maxi golden retriever breed two dogs two hyper dogs to the most friendly dogs so I have to tell the gender also because gender also very important in this example Maxi is male Kia is female golden ret rever is male and the lab roader is female so what happened is I went for a vacation for a long time for a week I went to my home so I was cleaning my home okay we all all the family members we are cleaning our home we will always leave our dogs in the home because dogs we cannot treat them as a dogs that is why I told those are my children so children you should not tie them you should leave them because they have to play right so we'll always always live there but what they doing is they coming in between and they're disturbing us while cleaning our home I was like okay we have a cage also when they're disturbing us a lot we'll take them and put it in a cage usually we will not do it but this time we have to do it because they're disturbing a lot what I did is Kia I took Maxi I took put it in one cage one cage now thid is a place wherein cloudy you'll be finding the climate exactly like Bangalore only AC climate so it was during the rainy season it was raining heavily okay the weather was awesome good so we were busy in our cleaning okay we were cleaning cleaning cleaning so at the end the cleaning is done evening it is cleaning is done so we just left the dogs after some time I came to Bangalore and started to teach to my dear students out there so after some month I got a call from my brother my brother is also there he's also a teacher got okay so now he called me and told that good news I was like good news so please specify because I'm an Indian I think otherwise okay so please specify he's like children are coming man you are younger than me huh what is this really huh don't take me wrong brother we are getting a children Kia is pregnant is what my brother told now Kia is pregnant so we very happy that she's pregnant and now why because more children are coming to a home they very happy but now the one only question is that what kind of a puy we will get because Kia lab rer Maxi golden retriever we will get lab rer we will get golden retriever what breed we will get you're completely confused and we were like okay we will not search in the Google instead we will wait until the puppies come and we will only see we will get the lab rer or we will get golden retri we waited we waited we waited one day finally arrived wherein Kia gave birth to wonderful five puppies five puppies five puppies so what happened is one puppy one more puppy in my hand one puppy one more puppy brother's hand one more puppy sister's hand we were looking at this what kind of a breed is this we were literally shocked it is not lab Rader it is not golden retriever mix we got and what is that mix sir if you ask me that breed only we call it as golded door what is that gold Ador gold is from Golden Retriever Ador from Labrador and then we searched in the Google that how these dogs looks like when they become adult these dogs you know Kia and Maxi hyperox lab golden R River their product of it you just think about it huh fully excited dogs High energetic dogs maybe Kia and Maxi will always sleep sometimes but the children of them no sleeping at all four puppies we have sold it one puppy is already there with us it is there with us hyper dog very hyper okay but what I'm trying to tell is what you got pure breed you got or what breed you got high breed tell me is it there in the real world yes it is there in the same way in Java also is it there yes it is there and how to tell this hybrid sir if you ask me watch it I'll get this good now you can see my friends we have this kind of a uml diagram already so I want to improve this uml diagram what do you mean I'll go above here and I will put one class like this and this class I will tell it as grandparent like this good I'll not stop I'll go above again here and here I will turn it as great grandparent like this good and now what I will do the height what I've given in the parent I will take it and put it in the great grandparent the read books what I've given in the parent previously I'll put it in the great grandparent the great grandparent will give birth to grandparent grandparent will give birth to parent and parent will give birth to child one child two and child three if you look at this kind of inheritance actually it is a mixture of two or more things hybrid means what mixture of two or more things lab Rader golden retriever hybrid like that loan's jeans loan you know very good lion jeans tiger jeans is mixed together you know this this will lead to one product do you know what is the product lier lion and tiger l i g and if you look at this you know lion strongest tiger even more strongest product of this you just imagine you can go to the YouTube and search lier there you'll get a big animal and you'll always get a doubt is it a loyal or tiger full confusion is there but what I'm trying to tell is hybrid means is the combination of two or more different things is nothing but hybrid if you look at this this kind of inheritance is a mixture of two or more things now what are you trying to tell what's this if you look at from great grandparent to this parent this is one kind of inheritance what kind of inheritance very good this is multi-level inheritance see there great grandparent grandparent parent three classes like that multi level from parent if you look at these children this is one kind what is this this is hierarchical inheritance yes or no is it not the mixture of two or more kind of inheritances yes that is why it is known as what Hybrid inheritance because the mixture of multi-level and hierarchical sensing this much difficult easy difficult or easy easy easy okay now let us see will this work or not for that let me get this at this point of time you have the parent you have all the three children child one child two child three now I will create great grandparent and grandparent now let us see how it will work I'll come here and I I will tell this class class what grand grand what parent like this good so after this grandparent I need great grandparent also I'll create him first so instead of me typing it I'll just copy I'll come here I'll paste it and I will do it as what great very good great grand parent like this good so now great grandparent is having what height and read books but actually in my program it is there in the parent so let me take it out I've taken it out I'll go to the great great grandparent I'll put it like this you can see this is how you're getting it awesome so now I'll come down you can see here what you have great grandparent you have it inside that what you have height and read books great after that what do you have grandparent and grandparent should do what extends very good I will tell it as extend extends what extends great grandparent like this so now Grand parent is also ready let me come down parent what parent is doing very good he is extending that is what I'm doing extending extending what sir grandparent like this when you do that you can see the height and read books from here it will come here from here it will come here from here it will come to all of these three Clos proc and that is what I'm showing you in all these three children it is coming for your naked it is invisible but something is there you want to access it what you should do create an object of this guy this guy and this guy because I want to see from here is it reaching there or what I've created the object in the main method you can see created the object and accessed height and read books from Child one from Child two from Child three let us see what I put I will get I'll save it and I will execute it you can see this is the output and this kind of inheritance we call it as what hybrid mixture of two or more different types of inheritance is the combination of different types of inheritance in one word if I have to tell you got this great with this we are going for the next one because now this kind of inheritance is done and dusted we going for the next one which is multiple let us understand with the help of an example now let us see in the real world if it is working in Java also definitely it will work so now let me start from scratch watch's this there is one mother I will tell it as parent one there is one more mother I will tell it as parent into there is one child I will tell as C1 what this child one is telling is Mommy to this parent one same time he is telling Amma to the parent to like this what you guys are looking at me like that tell me is this not possible huh so maybe you are thinking that it is possible because for your aunt also you'll feel that my aunt is like mother to me yes but I'm speaking about biological mother biological mother now this child can come from one mother itself yes or no but what he's doing there what is telling there I'm coming from this mother also I'm coming from this mother also is that possible it is not possible in real world in Java also it is not possible means what kind of an inheritance is this one child is inheriting from two parent classes or more parent classes this will not work in Java and this kind of inheritance we call it as what multiple inheritance and now let us see is this really the case or not in Java also let us see I'm having one class the name of the class is parent one I'll create one more class the name of the class is parent two I'll create one more class the name of the class is what child one child one is extending parent one is extending parent to I'll give one property here one Behavior one property here one Behavior good let us see how this will work now all of this I don't want it I'll just eliminate it let me start from the beginning what is that sir watch it let this main method be there I'll change it after some time what's this first what you should create you have to go at the top the hierarchy first is the parent one I'll create one class the name of the class is parent one and this parent one is having height ier us float float what height equal to 5.8 F like this good same thing I'll come here Behavior also void void what sir read books like this this is the method this is the behavior the parent will tell this way what he will tell I will will what read books like this that's the parent one I'll create one more class you have one more class as well who is that parent 2 I'll create one class known as parent to like this and now I'll open this close this so parent will be having certain color that color I will give it here like this and that I will tell it as brown like this I'll hit enter there is one Behavior as well he will tell I will not smoke that is what he's telling no smoke like this and he will put one statement also there what is that I will not smoke like this parent one parent two property be Behavior property Behavior I have to go for the next one who is that child one I have to create a class name of the class child one child one what is doing he's extending extending whom very good extending parent one if you see here now there is no problem if he's extending from one parent not POS I mean it is possible not at all a problem but what he's doing is he is extending parent one same time extending what parent and how to tell it parent one comma parent two you should tell and that is what I'm doing parent two like this if you do that straight away you are getting error in this comma if you ask me why is this he is telling why the hell you have given this comma I don't want this comma meaning don't tell him is what Java is trying to tell sensing this month great real world is it working in Java is it working absolutely no multiple inheritance will not work in Java at this point of time what is multiple inheritance one child is inheriting from multiple parents this is your multiple inheritance got this great see this great you call it as multiple inheritance let me tell you this multiple inheritance is also having the other names as well in interviews they can ask you this name also what is that it is known as Diamond inheritance it is also known as Diamond path inheritance like this it is also known as diamond shape problem means multiple inheritance will not work because of diamond shaped problem so these are the different wordings or words this multiple inheritance is having so you guys understood that why it is known as multiple inheritance but now the question is why the name Diamond given to it why the name Diamond to it why because you have a shape there a shape of a diamond what is the shape of a diamond there the shape of the diamond correct that shape you have it here that is why it is known as Diamond inheritance Diamond path inheritance you will be like sir you are telling this shape is a diamond but look at here sir this is the shape where is the diamond here there is a diamond there but you can't see it but Java can see it what are you trying to tell sir watch this if I create one class here the name of the class I will tell it as child one like this one class name I have given now there is one more class which is parent think that he's there but I'll will not tell it I want to extend that class extends parent parent is there again I'm telling you I haven't shown you good I'll create one more class the name of the class is demo one and this demo one will extend one class and that class is one class is there that is child one like this now I'll go above and I will get something there oh T come and sit here awesome what's this I'll create one class the name of the class is what parent like this good what's this who is the parent of [Music] child who is the parent of child parent correct who is the parent of demo one child one how you telling this because I have told extents my question to you is who is the parent of parent who is the parent of parent who is the parent of child one parent who is the parent of demo one child one how you telling this extense is there correct the same question I'm asking you who is the parent of parent no one correct why because there is no extense you're wrong you're wrong to your necked ey here extense is there good to your naked eye here extense is not there means why extense is not there you haven't given if you haven't given someone will give by default when he will give when you will not give he will give who is that sir jvm will give something there what he will give sir he will come here and tell it as extense like this and he will extend one Clause what is the name of the Clause sir object like that understanding now tell me my friends who has given this extense object jvm why you haven't given there that is why who has given that extens parent very good you have given this that is why I'm telling it as programmer extend child who has given this programmer when programmer gives it you can see it if jvm gives it you cannot see it but jvm can see it Java can see it sensing what I'm trying to tell the meaning of this is very simple you give there any class any class you give child one child two calculator anything I will tell class calculator I will tell extance one class the name of the class is what parent now who has given that very good you have given that programmer what if in case I'll not give anything I'll not give if you are not giving someone will give who will give sir jvm will give and what jvm will give sir he will tell extend extend what object like this so this point it should be there in the head forever understanding very good if this example you able to understand what's this tell me who is the parent of day 23 day 23 who is the parent of him who is the parent of him tell me have you given extense here no if you haven't given who will give jvm will give what it will give extense object it will give understanding very good in this case I'll come here above now I'll simply give only parent one now tell me my friends who is the parent of child one parent one why because you have given this you can see it let me go to the parent to tell me have you given xt0 something no then who will give jum what will give xtense xtense what object let me go above who is he parent one have you given xtense no who has given jvm can you see it no what has given extend sensing what I'm trying to tell very good now some students are thinking sir who is this object sir you're telling extense object extense object who is that object what's this see Java is a big guy is a big big ocean and inside this Java there is many many classes are there many many classes are there what are you trying to tell there is an inbuilt class known as scanner there's an inbuilt class known as integer there's an inbuilt Clause known as float there's an inbuilt Clause known as character there's an inbuilt class known as Boolean there's an inbuilt class known as bite there's an inbuilt class known as shot there's an inbuilt class known as string there's an inbuilt class known as string buffer there's an inbuilt class known as string Builder there's an inbuilt class known as scanner then an inbuilt class known as AR there an inbuilt class known as AR there's an inbuilt class known as string tokenizer there's an inbuilt class known as Bufford reader there's an inbuilt class known as file writer there's an inbuilt class known as thread there's an inbuilt class known as file reader there's an inbuilt class known as exception there's an inbuilt class known as throwable there's an inbuilt class known as stack Overflow error like this like this in Java you have many many inbuilt classes are there I have just given some variety but like this there are approximately 5,000 inbuilt classes are there in Java how many 5,000 out of all of these classes there is one class who is very very important who is that sir object and object is an inbuilt class in Java and is very very important why is important sir why because the creator of Java told that object is the root class of all the classes in Java the creator of java told that object is the parent class of all the classes in Java what I'm trying to tell is whether it is scanner whether it is shot whether it is integer whether it string tokenizer whether it is float whether it is file writer character all the classes in Java directly or indirectly is inheriting one parent which parent object directly or indirectly whether it is inbuilt classes or whether your classes directly or indirectly it will extend the object because he is the root class of all the classes in Java sensing this much so that is why Java always tell if you haven't given extents there he will give extents whom root Clause who is the root clause object sensing this much yes or no very good now with this information let us come back to the original one what is that this guy this is how currently my uml diagram looks like good tell me who is the parent of child one parent one who is the parent of child one parent two at this point of time think like that tell me who is the parent of parent one have you given anything there no if you haven't given anything who will give jvm will give what he will give extens object very good there is one class which is an inbuilt class the name of the class is what object like this you haven't given anything jvm will give now tell me who is the parent of parent to object very good and that is what I'm sh showing the object and tell me what shape you got there you got this shape which is the diamond that is why it is known as what multiple inheritance this is what you see which is visible for you but something you can't see but Java can see it that is why it is known as multiple inheritance it is also known as Diamond inheritance it is also known as what Diamond path inheritance tell me will this shape work in Java no that is why it is also Al known as a diamond shaped problem all of this is one and the same understanding great in interviews they'll ask you please explain multiple inheritance the way I've explained to you you have to explain in the same way first start giving real world example sir to explain about multiple inheritance let me explain to you will this work in the real world or what take two parent take one child ask him how you should ask how you should ask huh is this possible you are not teaching there you're explaining there you should not ask him instead what you should tell sir one child cannot inherit multiple parent in the real world in Java also you cannot do this this is what you should tell and you should not stop you should tell multiple inheritance is also known as Diamond inheritance Diamond path inheritance diamond shape problem then you should go on explaining so for him parent is there for him parent is there for him I haven't given the parent jvm has given the parent that is object for him I haven't given the parent jvm has given the parent that is object look at the shape sir this is diamond shape that is what is known as Diamond path inheritance Diamond inheritance understanding this very good now if I have to speak technically why this is not possible in Java if I have to speak technically very simple watch this what what I will do I will give I = 9 I equal to 9 I'll give I = 99 like this I'll come to this child one and I'll print this I tell me which I should get printed see this will not work already you guys understood but technically I'm speaking that okay sir in real world it is not working here also it is not working everything is fine Technic you have to speak now tell me why this is not working I = 9 I = to 99 what I'm doing here I'm printing I tell me this 9 will it reach here no it will reach will this 99 will reach here think that it will reach here correct now tell me you're printing guy 9 should print 99 should print huh you guys are understanding the question what I'm trying to tell I9 I 99 what you will get think that I9 I9 both he will get I'm printing guy inside this what do you have n you have 99 you have what should get printed there 99 how 99 who's giving the answer how 99 you guys are getting confused right yes or no why because there are two eyes there how how come Java will think that which I should print he's getting confused correct in the same way he's getting confused here that is why it is an err understanding yes or no very good multiple inheritance will never work in Java at this point of time but you can make it work and how to make it work in a concept known as interfaces I'll explain to you but at this point of time it will not work good with this let me proceed further to the next one which is the last one multiple inheritance is done let us go for cyclic inheritance is just one minute concept let us see now directly I will show you the uml diagram what is that b4l diagram I'll draw one guy here or maybe a mother not guy parent that is Mother good there is a child also so What Child Is Telling is Mommy to the parent now what parent is telling is Mommy to the child got shocked right yes whatever you are seeing here this only we call it as what cyclic inheritance think and tell me is this kind of a thing is there in the real world it is not there that is why in Java also it is not there what I'm trying to tell is we have a parent we have the child no doubt child will come from the parent but parent will never come from the child like this so now if I have to represent these Arrow marks in a different way I'm representing it like this child is extending the parent and parent is extending the child so you have a cycle form there and this we call it as what cyclic inheritance what do you think will it work it will not work in Java got this great now let us get my program and show you that is this really the case or what I'll get the parent there parent one inside parent one I'll will not quote anything child one is also there child one is extending the parent child one is coming from the parent one not at all a problem but when you come here and tell that parent one is coming from what child one look at him parent one extend from Child one so when you do that you can see an error and if you want to see what is an error take this cursor and hold on this it is showing you something what is that oh let me display okay what are you showing cycle detected means there's a cyclic inheritance that will not work in job understanding great so how many inheritances we have seen six inheritances out of six how many of them will work in Java yes one 2 3 4 will work this and this will never work in Java understanding great so an interviews is a very famous question what are the types of inheritances please explain with an example all the six you have to explain and four you should tell it will work in Java two will not work in Java that is how you should explain and if I have to tell you some you guys came in the month of June right in the month of I think it is March April May there's some 27 students who got placed for a company known as epam epam is the name of the company 27 students at one shot and do you know what is the package epam offered 8 lakh per anom you go and ask to all the students out there what questions were being asked many questions on DSA questions on collections questions on Advanced Javas for some of them but all of them got the oops questions also and in that oops questions this question was there for all of them what is that types of inheritance explained with the help of an example all of them and please tell me what will work what will not work got this this is very important way have explained to you explain in the same way there's no way that you'll get rejected understand it great in this one more very important question is that fifth guy who is he multiple inheritance they'll ask you that multiple inheritance is it possible in Java at this point of time you should tell it it is not possible then they'll ask you why is that please explain you have to explain everything then he will ask the cross question what is known as Diamond inheritance Diamond path inheritance then you should tell so there's a diamond ship oh where is the diamond ship there only two parents one child where's the diamond shap then you have to explain about that object class the way I explained to you I've drawn so many classes right like this you should tell object is the root CL of all the classes in Java any class directly or indirectly will extend object so this is the way you have to explain and after that you have to bring this diagram and tell that look sir parent one extending object parent two extending the object so that is diamond shape problem Diamond path inheritance Diamond inheritance got this great very important make sure you practice it hundreds of times lot of times this question is being asked good thank you so much I'll stop my discussion here itself today tomorrow we'll understand about construct a China you already seen the Constructor chining we have already seen the Constructor chining am I correct where we have seen this in encapsulation how you will do Constructor chining in one class itself correct from one Constructor to another Constructor in the same class but now I want to achieve the Constructor chining from one class to another class and that you can do it with the help of inheritance what is this all about tomorrow you should come to my class explicitly I stressing this why tomorrow is Friday you think Friday is weekend weekend means rest day so please come to the class tomorrow is a very important concept thank you I