Well, we've completed our second "flyby" of the key principles of OOP. We studied polymorphism and encapsulation in greater detail. We also learned about a new concept: abstract classes. That said, these topics aren't as simple as the other topics you are already familiar with. So feel free to use the following articles to bolster your knowledge and clarify the subtleties that will almost certainly be asked in your future interviews.
Relationships between classes. Inheritance, composition, and aggregation
In software development, you will quickly realize how important it is not to write superfluous code. Fortunately, Java has everything you need to elegantly "cut back". This lesson clearly describes relationships between classes: inheritance, composition, and aggregation. Prepare yourself: there will be many interesting examples.
Principles of encapsulation
Encapsulation versus hiding — are they different concepts or the same thing? In its basic form, you have already encountered encapsulation more than once. If you want to know how to "hide" the complex inner workings of your program from the user and expose only a convenient interface, then we recommend that you read this lesson carefully.
How to use polymorphism
Polymorphism's main advantage is flexibility. On the one hand, you can work with several data types as if they were the same type. On the other hand, this principle lets you preserve the behavior of objects. When do you need a uniform look, and when do you need unique characteristics? We'll talk about that.
Why interfaces are necessary in Java
Without rushing anything, this lesson describes in detail what interfaces are and why they appeared in the language. You will also learn about popular interfaces in Java. Prepare yourself! This topic has a sequel!
The difference between abstract classes and interfaces
In this lesson, we talk about how abstract classes differ from interfaces and look at examples involving commonly used abstract classes.
We devoted a separate lesson to the differences between an abstract class and an interface, since this topic is so important. You will be asked about the difference between these concepts in 90% of your future job interviews. So be sure you understand what you read, and if you don't understand something completely, then read additional sources.
GO TO FULL VERSION