Java Video Tutorial 15

Code is Here:

Best Java Book :

In this part of the Java Video Tutorial I cover interfaces, abstract classes, abstract methods and more.

You need interfaces and abstract classes because Java doesn’t allow you to inherit from more than one other class. You would use an interface when you want to force the user of the interface to create every method in the interface.

You use an abstract method when you need some flexibility.






33 responses to “Java Video Tutorial 15”

  1. AkShay Mahajan Avatar

    Derek Sir u are the best….

  2. James Kennedy Avatar

    Why create the setWheels and setSpeed functions in Vehicles? Aren't those variables already set by the Vehicle constructor?

  3. Khaled Saif Avatar

    Great tutorial but too fast too furious 🙁

  4. ManyStandAlone Avatar

    I'm just glad you speak clear english and don't sound like you are trying to swallow your uvula when you talk.

  5. Troy Jones Avatar

    So basically an interface is the C++ equivalent of a .h file?

  6. Jeda Maderse Avatar

    Too fast. I didn't understand a little. Lol. xD

  7. Rithik Kumar Avatar

    Is it important to add 'this.' to the beginning of the variable? Will it work if you just use the variable name?
    At 3:54, will "return numOfWheels" do the same thing as "return this.numOfWheels"?

  8. Dimitris Ladakis Avatar

    So whats the point? Why do we have to create the interface in the first place? why not just writing the vehicle class??

  9. Shane Saunders Avatar

    One thing that may be helpful (at least when using Eclipse)… When you want to add the methods from the interface, you can right-click on the class name and select "add unimplemented methods". This is much easier than manually pulling them in like he did.

  10. Sarrah Wilson Avatar

    Do you have a tutorial for buffered reader and writer to a text file? I need to read a text file and write to a text file.

  11. believe theUnbelievable Avatar

    can interface be  a type and if yes what are the advantages of that??

  12. Harish Shankar Avatar

    I don't know how many of you encounter this video, but if you do – you probably have the same question as the others through these years.

    "What's the point?"

    Think of how professional organizations work. You need common standards and consistent development across all your teams. This means, when you create a custom object you would like all of them to have some methods such as setters, getters to name a few. This might help for testing and countless other purposes.

    The fact that we can enforce a hard template like format only makes work easier, sort of like a rule book that everyone follows.

  13. magmasceptre Avatar

    how come youCrashed() didn't require the abstract declaration?

  14. Abdulaziz Al-Fageeh Avatar

    Hi, I appreciate your effort, and I thank you sincerely, and here are my questions:
    Why use an interface if you're going to define everything in a different class?
    I know that this might sound dumb, but I'm still new at this: Isn't it possible to employ multiple inheritances by using multiple extended inner classes?
    I've read two books on Java, but I still don't get this "implements" business, and extending classes seems, to me, just an economic way to use fewer words and that is all.
    Now, I'm certain that I'm wrong. But could you help by answering my questions and directing me to resources that could enlighten me on the subject?

  15. Icarus Avatar

    The tutorial helped a lot, you're a good teacher but it's going a bit fast. Maybe that's just because my English is bad and I need time to take it in though. And I'm sure you improved in 5 years 😉 I'll make sure to check out your other video's, thanks again

  16. Manuel A. Alonso Tarajano Avatar

    Dear Derek,
    B R E A T H …
    u simply talk way too fast! Like in a rush. If you intend to communicate properly … make ur self it easy to follow.

  17. anass benayed Avatar

    Super helpful..! Thanks

  18. Dukez Venom Avatar

    interfaces and abstract classes seem so useless…..

  19. shashgo Avatar

    Im a little confused on the difference between abstract classes and interfaces. They both seem to do the same thing, except that abstract classes can have empty methods and implemented methods, whereas interfaces can only have empty methods. Why then is there a need to use abstract classes over interfaces? Is there a reason for methods to have bodies in abstract classes like Crashable versus being implemented in the class that extends the abstract class like Vehicle? If you can omit the bodies of all of methods in interfaces as you did in the interface Drivable, and then define them in your class Drivable, then what is the advantage of using an abstract class?

  20. Tim Andress Avatar

    Loving your videos! I'm surprised you're doing this for free, great explanations! I now completely understand how to build an abstract class and use interfaces. The purpose of adding that functionality to program will eventually come along in my weekly Lab so I'll probably be watching this video a few more. Thanks again!

  21. Mhommad Hamza Avatar

    what is the point of making an abstract class ? we just defined a method in it and called it from main just like we would do with a normal class

  22. sricharan kowlali Avatar

    How many of you noticed that he plays minecraft.

  23. ThatsRight Avatar

    Take a breath mate..

  24. BCwithPC Avatar

    I'm super confused

    Please respond ASAP anyone who knows the fix to this.

    Whenever I type something like "public void setWheels(int numWheels){
    this.numWheels = numWheels;

    The line that says "public class Vehicle implements Drivable{"
    gives me an error saying "- The type Vehicle must implement the inherited abstract method Drivable.setWheels()

  25. CAROLINE Avatar

    I don't get why class which uses interface has to use whole abstract methods.

  26. CAROLINE Avatar

    interesting video,thanks.
    So, interface is for lots of class to have the same style like making name of method?
    and doesn't make confusing stuff.. am I right?

  27. Sebastian Farias Avatar

    well, that does it, min 2:09 and it was as clear as it can possibly be!!!
    Derek, you are amazing!!

  28. Brian Tep Avatar

    i didn't understand this tutorial as well as your other ones, could you use some UML diagram to help explain some of these 'simple' concepts?

  29. TheBlue8ird Avatar

    I didn't understand what IS actually interface, and what does it help the code? Like, in what cases?

  30. GobblowGalaxyGamer Avatar

    Can you please explain what implementing does as I didn't understand that?

  31. Collin Alpert Avatar

    But why do I need an Interface if I have to override the methods in my class anyway. It seems to me, that I just have to type stuff twice.

  32. Rishi Swethan Avatar

    Thanks for replying for my previous doubt!
    I agree that we can't use many extends keywords to inherit multiple classes, but why can't we simply create objects of the class that needs to inherited and use it? why is interface coming into play?

Leave a Reply

Your email address will not be published. Required fields are marked *