 Hello friends. I am Sanjay Gupta. In this video, I am going to demonstrate you how you can use final keyword so that a class cannot be inherited in Java. Before starting, you can note my information. You can subscribe my YouTube channel by clicking on the link which is available at bottom right corner of this video. You can download my app Techimus that is available on Google Play. You can connect with me by following other details which are available in front of you. Now coming on to the topic to understand the concept. First, I am implementing two classes. First one is class A. Inside class A, I am implementing a method which is show and inside this method I am using system.out.println and it is containing a text message that is A. Second class is B which is extending class A. This way I am applying inheritance class A superclass and class B subclass. Inside this class, again I am implementing show method and with the help of system.out.println, I want to display text B on console. So friends, this is a simple example of inheritance class A is inherited into class B. Now a problem or a requirement is that if we don't want to inherit a particular class, then you can do it with the help of final keyword. So suppose if you don't want that a class A will be inherited into another classes, then you can make a particular class as final. So if you have declared a class as final, then it cannot be inherited by another classes. So you can see that an error message has occurred here which is showing the type B cannot subclass the final class A. So here class A is final class. It means class B cannot inherit members of class A into it. So this way you can prevent inheritance with the help of final keyword in Java. I hope you have understood the concept how we can use final keyword to prevent inheritance in Java. If you want to watch more programming related videos, you can subscribe my YouTube channel. You can connect with me by following these details which are available in front of you. Thank you for watching this video.