8.21 Interface in Java Tutorial with Example

///8.21 Interface in Java Tutorial with Example

8.21 Interface in Java Tutorial with Example

FavoriteLoadingAdd to favorites

Multiple inheritance is not allowed in java and a class can only extend one parent

Java468x60

class. Interfaces provide a form of multiple inheritance. Interfaces are not classes,

however an interface can extend more than one parent interface.

Interfaces provide a form of multiple inheritance. A class can extend only one other class.

Interfaces are limited to public methods and constants with no implementation.

Check out our website:

Follow Telusko on Twitter:

Follow on Facebook:
Telusko :
Navin Reddy :

Follow Navin Reddy on Instagram:

Subscribe to our other channel:
Navin Reddy :
Telusko Hindi :

Subscribe to the channel and learn Programming in easy way.

Java Tutorial for Beginners:

C Tutorial Playlist :

Android Tutorial for Beginners Playlist :

XML Tutorial :

Design Patterns in Java :

Socket Programming in Java :

Spring MVC Tutorial :

OpenShift Tutorial for Beginners :

Spring Framework with Maven :

Sql Tutorial for Beginners :

String Handling in Java :

Array in Java :

Java Servlet :

Exception Handling in Java :

source

By |2019-12-05T00:19:32+00:00December 5th, 2019|Java Video Tutorials|40 Comments

40 Comments

  1. MrAlexWatching December 5, 2019 at 12:19 am - Reply

    Oh bee jey

  2. Devilnero1991 December 5, 2019 at 12:19 am - Reply

    But why use an interface? If I delete the interface all that does is shorten my code, which is good! so whats the use of an interface?

  3. Mayureshwar Khurud December 5, 2019 at 12:19 am - Reply

    Your videos are just outstanding….we get to know new concepts in very less time as compared to other videos

  4. Babu Babu December 5, 2019 at 12:19 am - Reply

    Woo

  5. Babu Babu December 5, 2019 at 12:19 am - Reply

    👌

  6. Mystic Stardust December 5, 2019 at 12:19 am - Reply

    still quite confuse…

  7. Vladan Ulardzic December 5, 2019 at 12:19 am - Reply

    Well done ! Keep on …

  8. Bruno B. December 5, 2019 at 12:19 am - Reply

    Great explanation. Thank you so much! You're an outstanding tutor. Well structured video, concise and informative, as usual.

  9. Divyeshkumar Balar December 5, 2019 at 12:19 am - Reply

    I was trying to put variable in interface; but, i cant just declare it; i have to define it as well

  10. Jojo Mojo December 5, 2019 at 12:19 am - Reply

    sir thank you very much !!! You are best teacher!!!

  11. Pavan Krishna December 5, 2019 at 12:19 am - Reply

    3:57 it's not xyz it's Pqr
    Am I right ?

  12. Krishna Salampuriya December 5, 2019 at 12:19 am - Reply

    I was finding this from long time , finally got that from you , very very thanks….

  13. Virat Raj December 5, 2019 at 12:19 am - Reply

    Fantastic

  14. Venkat Maddirala December 5, 2019 at 12:19 am - Reply

    @telusko , please upload videos on java io

  15. shubham singh December 5, 2019 at 12:19 am - Reply

    u r doing a great job,one suggestion if u can upload all the tutorial program that u have used in the video on github

  16. debraj roy December 5, 2019 at 12:19 am - Reply

    interface abc{
    void show();
    }
    class abcImp implements abc{
    void show(){
    System.out.println("show");
    }
    }
    class telusko{
    static void main(){
    abc o=new abcImp();
    o.show();
    }
    }

    // what is the problem with this code??
    error:show() in abcImp cant implement show() in abc.

    please replya t the earliest

  17. sapna vats December 5, 2019 at 12:19 am - Reply

    As you said in your earlier video on interface that we cannot create an object of interface so out here while using anonymous inner class why are you creating on object of the interface Abc?

  18. Deepak Kumar December 5, 2019 at 12:19 am - Reply

    sir can u tell me the question which will ask durin interview on interface?

  19. Srinu Challagundla December 5, 2019 at 12:19 am - Reply

    Thanks for your great tutorials

  20. Ritesh Kumar December 5, 2019 at 12:19 am - Reply

    Excellent explanation.

  21. Love December 5, 2019 at 12:19 am - Reply

    how are u recording this at 7:10am?????? i can barely spell my name that time

  22. subrata kamila December 5, 2019 at 12:19 am - Reply

    I Have a query…. pls chk the program…. Its a interface …but we can define also….. how its possible…

    public interface Test2 {

    void hello();

    int Hi();

    static void Hey() {
    System.out.println("Hey….");
    }

    abstract void Abc();

    public static void main(String[] args) {
    Test2 t2 = new Test2() {

    @Override
    public void hello() {
    System.out.println("…its a Hello Method");

    }

    @Override
    public int Hi() {
    System.out.println("Return Zero");
    // TODO Auto-generated method stub
    return 0;
    }

    @Override
    public void Abc() {
    System.out.println("Its a Abc method");

    }
    };
    t2.hello();
    t2.Abc();
    t2.Hi();
    Test2.Hey();
    }

    }

  23. Aniket Tambe December 5, 2019 at 12:19 am - Reply

    Sir can we have variable in Interface

  24. Hemant Jadhav December 5, 2019 at 12:19 am - Reply

    hello sir….nice video

  25. Lil Rana December 5, 2019 at 12:19 am - Reply

    Sir can it possible that interface class method can define differently where different classes implements it.

  26. A2D Channel December 5, 2019 at 12:19 am - Reply

    Everyone? hv i heard everyone?? where's alien?

  27. Remi Stardust December 5, 2019 at 12:19 am - Reply

    I learned something I had not understood before! This was a good use of my time, thank you very much!

  28. Cak Farm December 5, 2019 at 12:19 am - Reply

    Subscribing.

  29. Piter Admski December 5, 2019 at 12:19 am - Reply

    what is the point with the interfaces ? I cant see functionality of this one. The Interface is created to inform me about some name of methods which I must to use and implement. And where is the sense? I use some classes with my method regardless, if I implements interface or not.

  30. Tej Patil December 5, 2019 at 12:19 am - Reply

    Hi Navin,

    I have a question regarding interface which I stumbled upon while working on exception. This is an example from Head First Java Book. Below is the code.
    import javax.sound.midi.MidiSystem;
    import javax.sound.midi.MidiUnavailableException;
    import javax.sound.midi.Sequencer;

    public class MusicTestException {

    void play() throws MidiUnavailableException{

    Sequencer seq = MidiSystem.getSequencer();
    System.out.println(seq.getClass().getName());

    System.out.println("we got Sequencer");
    }

    void sendTxt(){

    }

    public static void main(String[] args) {
    // TODO Auto-generated method stub
    MusicTestException mte = new MusicTestException();
    try {
    mte.play();
    } catch (MidiUnavailableException e) {
    // TODO Auto-generated catch block
    System.out.println("execption " + e);
    }
    }

    }

    Here I couldn't understand how MidiSystem Class can have a static method getSequencer of type Sequencer when MidiSystem Class doesn't implement the Sequencer Interface at all. here is the piece of code "Sequencer seq = MidiSystem.getSequencer();" This is bit confusing to me. When I looked into Java API for MidiSystem class where i never found the Sequencer implementation but in the code it says it can Instantiate Sequencer and getSequencer returns to interface. How is this possible? Please help me here.

  31. TAMIM HAIDER December 5, 2019 at 12:19 am - Reply

    Hello Sir, I have 1 question…ur saying interface is use to do multiple inheritance. But my question is in inheritance the method is already implemented we inherit the class and just reuse the method instead of rewrite it again….but in interface the child class has to implement the method…so where is the benefit of using interface if i have to implement the mhod in child class…

    The way you teach java its just amazing. Thanks a lot.

  32. Heriberto Cepeda December 5, 2019 at 12:19 am - Reply

    Loved it! Simply great 🙂

  33. Faz chow December 5, 2019 at 12:19 am - Reply

    Can you make a tutorial series on Scala Programming? Your tutorials are really helpful. Thank you for your effort. You make learning really easy and accessible.

  34. SkyDweller December 5, 2019 at 12:19 am - Reply

    very good vids

  35. SkyDweller December 5, 2019 at 12:19 am - Reply

    are you jesus?

  36. Michael Knox December 5, 2019 at 12:19 am - Reply

    i like the way you explain these examples, it is very creative..

  37. Tanmay Sharma December 5, 2019 at 12:19 am - Reply

    when there are more than 1 method in interface then how to use lambda expression

  38. Akshay Gulati December 5, 2019 at 12:19 am - Reply

    +Telusko learnings…can u suggest something abt this error…

  39. Akshay Gulati December 5, 2019 at 12:19 am - Reply

    class A{
    int i=5;
    }
    interface B{
    int i=6;
    }
    class C extends A implements B{
    public void show()
    {
    System.out.println(i);
    }
    }
    class main{
    psvm(String…a){
    new C().show();
    }}

    this program shows ambiguos error. Can any1 explain it??

  40. Mohammed Viso December 5, 2019 at 12:19 am - Reply

    Thank you

Leave A Comment

*