When I studied at the university, it was quite hard for me to understand OOP (Object-Oriented Programming), now I understand that we were just taught OOP with not quite clear and correct analogies and in general, it seems, the teachers themselves did not quite understand what the essence of OOP .
Remember, the classic analogies of the PLO, there is a class “Pets” with the methods “voice” and “is”, from it we inherit the Cat and the Dog and everything is fine.
But here comes the Light and brings aquarium fish that do not talk, and then comes Vasya, who brings a favorite cactus, which not only does not talk, but does not eat.
')
We are already confused, but Little Johnny asks: “Where are the static methods, interfaces, abstract classes in this zoo and how does a class object differ from a class itself?”. It is certainly possible to explain, but difficult. Understand, even more difficult.
Or another classic example, here is a rectangle, from which one wants to inherit a square (well, logically, a square is a special case of a rectangle), but a rectangle has a length and width, and a square has only one side. Something is confusing here too.
Now we will think how to explain OOP better?
Object-oriented programming is not a description of objects in the real world (more precisely, not only and so much a description of the real world), it appeared from design technicians (before the advent of any computers) from all engineering bureaus, building architects, equipment designers, etc.

So, imagine an aircraft manufacturing company and a design office at this company (well, let's say, Boeing). We ordered several models: military aircraft, cargo and passenger.
The first thing we will do is start drawing some general drawing for all models. According to this drawing, it is still impossible to build a real aircraft, but it already contains general implementation details. This is an
abstract class.Java codepublic abstract class { // ;
public abstract void ();
public void () {
//
}
public abstract void ();
}
, , , , ( , ), , , .
.
Javapublic interface { //
long get();
double get();
long get();
void ();
void ();
void ();
}
public abstract class implements {
...
, , , , (/)
.
Javapublic abstract class { // ;
public abstract void (); //
public void () {
//
}
public abstract void (); //
}
, . . , , . , , .
.
Javapublic class extends {
public int get() {
return 120;
}
public void () {
__();
_();
___();
():
}
...
}
public class extends {
public int get() {
return 5;
}
public void () {
_();
_();
():
}
...
}
() . , , , .
() .

, , . .
.
2 , , (, ) , ( , ).
.
Javapublic class extends {
...
public void () {
_();
___();
___();
():
}
...
}
public class extends {
public void () {
_();
_();
():
}
...
}
, , ( ), « - ».
.
Javapublic class extends {
private = new 45()
...
}
, (, , ), .
.
120 , - 130 ( ), , . , - 120 , 130 , , , .
.
Javapublic class 130 extends {
@Override
public int get() {
return 130;
}
...
}
?, , . , . , - (, , ), - () .
, , , . . .
( ), , , , - (, , , ), , . — . — ..
!
P.S. (,
Java SE)