Imports and extends

can someone explain "While we import the package, we can use all its public functions, Then what is the point of extending the class?" "I have been studying OOP Langusges for 3 years and I have not received an answer to this question."

+3
source share
5 answers

A class extension, if for inheritance, the OOP mechanism, it has nothing to do with import, when you import, you actually import all classes in relation to the imported package, unless you import certain classes of the package.

, , , . , ...

, , , , ,

, , .

,

+3

.

, importa java.util.*, . , ( ) ( ). , .

(inheritance - ) , . . , , accessor (public, protected ..), (void, int, someObject ..) , . , . (/) .

is a. , .

+3

. , . . , . .

, , Finance, EuropeanBanker. , , . , ( , , ). , Banker . Banker. , Banker , .

EuropeanBanker UniversalBanker, , . , , , . , , EuropeanBanker. , ..

, , . , , .

+1

While you are importing a class from a package, you can use it through its instances, but if you extend the class, you will have access to the members of the class through 'this', and the keywords are 'super',

+1
source

In Java, a class extension allows you to replace for it, as well as use its protected members. Protected methods cannot be called by arbitrary classes in other packages.

0
source

Source: https://habr.com/ru/post/1760220/