 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can implement interfaces 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 Tachymus that is available on Google Play. You can connect with me by following other details which are available in front of you. Now coming onto the topic, first I will be explaining the concept of interface. Then I will be demonstrating an example so that you can understand what is interface. So first point says using the keyword interface, you can fully abstract a class from its implementation. Second point says using interface, you can specify what a class must do but not how. It is because we don't have to define definitions in case of interfaces. We just have to declare methods. The definitions will be provided by the classes which implements interfaces. Third point says interfaces are syntactically similar to classes but they lack instance variables and their methods are declared without any body. Just I explained you in point number 2. Last point says any number of classes can implement an interface and also one class can implement any number of interfaces. So this is a brief about interfaces. Now this is a syntax through which you can define interface. Here first is access then interface and then interface name. So I am highlighting these three terms. This access means it can be public or default. This interface is a keyword and name is the name of interface which can be any name. This is another requirement of the programmer. Inside this definition, you can define any number of methods like this. Sorry, you can declare any number of methods not defined. So you have to use return type, then method name and then parameter list. Similarly, you can define second method or you can define n number of methods. You can declare variables like this type, then final variable name equals to value. Remember that whenever you are using or you are defining interface, all variable must be final in case of interfaces and you can declare n number of variables as final in interfaces. So this is a brief about interfaces. Now moving on to an example. Here you can see an example is available in front of you. So first import statement which is importing scanner class, which is available in util sub package. Then line number two to line number six. These statements are defining an interface interface name is person. And it is containing two methods declared. First one is read and second one is show. After interface declaration, you can see a class student which is implementing person interface. For that purpose, I am using implements keyword. So if you are inheriting a class, then you have to use extends keyword, but if you are implementing an interface in a class, then you have to use implements keyword. Inside this class, two variables name and roll number are declared. Then first method read, which is declared inside interface is defined. So inside read a method first scanner class reference input is created. Then with the help of system.out.println, this message enter the student name will be displayed on console. Then input dot next time will read a text message and that entered value will be assigned into name. Then enter the roll number will be displayed. Then input dot next and will read a roll number that will be assigned into roll number variable. This is the complete definition of read. Now second function, which is declared inside interface. That is show, which is defined further inside show method. You can see that two system.out.println statements are available, which are displaying student name and student roll number. So these two statements are pretty simple. This is complete definition of student class. Now you can see class test is defined, which is containing main method inside main method. Person P reference is created. This is reference of interface. Now P equals to new student. It is creating an object of student class. So friends, if you are creating reference of interface, then it can refer to a class who has implemented that interface. So here P is reference of person interface, which is referencing object of student class. So this is correct notation. Then P dot read is calling read method, which is defined inside student class. Then P dot show, which is also defined inside student class. So friends, this way we have implemented interfaces, which is containing only declarations of the methods. And those declarations are defined by the class, which is implementing that interface. So in this example, person is the interface, which is implemented in student class. Now I am going to execute this code. So you can see that it is asking for name. So I am entering my name Sanjay. It is asking for roll number. I am entering 22. You can see the output student name and roll number. Both are displayed here. So friends, this is the simple demonstration so that you can understand the working of interface. So in this example, I have implemented, first of all, an interface person. Then student class, which is implementing person interface and defining two methods. The given show, which are declared inside interface. Then third test class, which is creating object of student class. And that object is referenced by a P reference, which belongs to person interface. So you can implement this example in your system so that you can understand the working of interfaces. If you want to watch more programming related videos, you can subscribe my YouTube channel. Thank you for watching this video.