 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can override generic classes in Java. Before starting, you can subscribe my YouTube channel by clicking on the bottom right corner of this video. You can download my app that is available on Google Play. You can connect with me by following these details which are available in front of you. Now coming on to the topic. In this demonstration, I will be overriding a generic class. So here you can see class Jan that is a generic class is defined. It is having an object of type T, then a constructor that is receiving O and that O value will be assigned into OB. Then go get OB method is defined, which is returning OB and it is printing a message Jan's get OB. So when a simple object of Jan class will be created, this method will be called. But in this example, this Jan class is inherited into Jan2 class, GEN2. So it is extending GEN class, generic class. You can read the comment a subclass of Jan that overrides get OB. So here, get OB method is defined, which is overriding its superclass get OB method. Before that, a constructor is defined, which is receiving O as an argument and that O is passed in superclass using super keyword. Then go get OB method is defined. Here, messages different Jan2s get OB is displayed and it is returning OB as an argument. This OB is belonging to superclass. So when object of superclass will be created, then superclass get OB method will be called. But if object of subclass, that is GEN2 is created, then get OB method of GEN2 will be created, sorry called and this will return value of OB that is available inside superclass. Now, you can see Jan demo class is defined, which is having main method inside main method. First object I OB is created of GEN class. It is for superclass and it is calling, sorry, it is having an argument 88. Then Jan2 class object I OB 2 is created. It is having an integer value. Then Jan2 class str OB 2 is created, which is having string generics test as an argument. Then I OB dot get OB, I OB 2 dot get OB and str OB 2, get OB is called. So this first statement system dot out dot println is calling superclass get OB because I OB belongs to GEN class only. Best of two statements are calling get OB methods of subclass because I OB 2 and str OB 2 belongs to GEN 2 class. So these two statements are overriding superclass get OB method. Now I am executing this code. You can see the output. First output displayed with the help of GENs, get OB method. But rest two outputs are displayed with the help of GEN, sorry, first output is displayed with the help of superclass GENs, get OB method. Rest two outputs are displayed with the help of subclass that is GEN 2 and it's get OB method. So friends, here if I am creating object of superclass, then superclass get OB method is working. But if I am creating object of subclass that is GEN 2 and I am calling get OB method, then subclass get OB method is working properly. So with this way, you can apply inheritance between generic classes. You can override their methods as well. So I hope you have understood the concept how you can override methods which are available in generic classes. If you want to watch more programming related videos, you can subscribe my YouTube channel. Thank you for watching this video.