Java Video Tutorial 15

Code is Here: http://goo.gl/8I3sW

Best Java Book : http://goo.gl/FtKp0m

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.

Comments

Sarrah Wilson says:

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.

GetMet says:

Also, in the LessonFifteen class, Shouldnt the object be of Drivable type??

Harish Shankar says:

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.

Золотая Невеста says:

Hi Derek. You omitted the access modifier and “abstract” keyword when you declared members of the interface why is that?

TheBlue8ird says:

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

GobblowGalaxyGamer says:

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

Rishi Swethan says:

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?

shashgo says:

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?

Kendall Christlieb says:

I can’t tell you how helpful your channel has been to me to supplement my online college class where I have just felt lost reading the textbook. Thank you so much! Straightforward and approachable – couldn’t ask for more!

Norbert Hreskó says:

So, basically interfaces are just guidelines ? Does it mean that if I want to make something drivable, it just tells me that I need to implement all the methods from the interface in order to do so ?

Tom Steinmeier says:

Nice video.

Khaled Saif says:

Great tutorial but too fast too furious 🙁

Bad Content says:

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()

Luis Martinez says:

I don’t get it. It seems that you define the interface, the abstract class. You “create” the methods inside the interface and the abstract class, but then these methods are defined again, and what they do, inside the class Vehicle. So I don’t understand the point of the interface and the abstract class here. If you are defining the methods anyway within the class, then it seems to me that even if you remove the interface and / or the abstract class, the output of the program LessonFifteen would be the same. Could someone please clarify? Thanks

Tim Andress says:

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!

sricharan kowlali says:

How many of you noticed that he plays minecraft.

Luis Martinez says:

I didn’t understand the point, gonna watch a second time

Steve Ho says:

Can someone help me understand this? I dont get the point of using an interface. Can’t we just add more methods to the object class?

Dukez Venom says:

interfaces and abstract classes seem so useless…..

DARPAN ANEJA says:

Awesome

Troy Jones says:

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

Sebastian Farias says:

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

Dimitris Ladakis says:

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

clarke says:

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

Justin Herrera says:

no explanation Im still confuse.. I just wasted my time watching this video

clarke says:

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?

peraruor says:

Thanks Derek, realy simple but at the same time complete explanation on interfaces. However, I got a question on interfaces if you please. I’ve seen on patterns examples the use of interfaces as variables. Why you need to use an interface as a variable type on a program? If interfaces don’t have methods implementation, Why used as a variable? Thanks again. Pedro.

believe theUnbelievable says:

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

Brian Tep says:

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?

Devon Langendoerfer says:

Great video, thanks!

ManyStandAlone says:

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

Manuel A. Alonso Tarajano says:

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.

 Write a comment

*

Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!