This is the beginning of the end of the Basic Java unit.
With that said, you will still be learning Java throughout the future Units, so keep your minds open and ready to learn!
In this lesson, we will be discussing inheritance and interfaces (not in extensive detail, as they will come up frequently in future Units and it is easiest to understand them as you manipulate them yourself).
Since this lesson is the culmination of the previous lessons in the Unit, we will be applying much of what we learned previously.
If you need to refresh your memory, refer to the previous lessons!
Let's get started!
Lesson #1-19: Interfaces
If you've ever seen highly functional Java code, you might notice something like this in the class declaration:
Yeah, that's quite a mouthful... so you can think of it this way.
An interface is a collection of abstract (meaning that it's not really used, but it's just there as a reference) methods and constants that define a group.
If a class implements this interface, then it will "inherit" all the abstract methods and constants.
For example, let's say we have an interface called Human as below:
In other words, King is saying that, first and foremost, he is Human.
When you implement an interface in a Class, you must define everything you have defined in the interface. That means the King cannot remove the pee() method from his Class because he is, after all, only human.
Lesson #1-20: Inheritance
This is a very similar topic to interfaces.
The key difference is that inheritance deals with two classes, not a class and an interface.
Another key difference is that inheritance uses the keyword "extends" rather than "implements."
So how is "extends" different from "implements?"
Recall that when you implement an interface, you must take all the qualities of the interface and apply it to the Class that is implementing it.
Not so when a class extends another class, which we refer to as a Superclass, and the extending class is called a subclass.
A class is a blueprint for objects, as I have repeated over and over again.
A superclass is a blueprint for other classes.
Let's have a look at an example:
Not an extremely long lesson, but this is a very important one. Read through it thoroughly!
One more thing...
If each of you told your friends about this tutorial and asked them to like us on Facebook, it would help us out tremendously.
Take the time to support Kilobolt! :D
