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."
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.
, , , . , ...
, , , , ,
, , .
,
.
, importa java.util.*, . , ( ) ( ). , .
importa java.util.*
(inheritance - ) , . . , , accessor (public, protected ..), (void, int, someObject ..) , . , . (/) .
is a. , .
is a
. , . . , . .
, , Finance, EuropeanBanker. , , . , ( , , ). , Banker . Banker. , Banker , .
EuropeanBanker UniversalBanker, , . , , , . , , EuropeanBanker. , ..
, , . , , .
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',
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.
Source: https://habr.com/ru/post/1760220/More articles:jQuery, JSON, search, etc. - jsonПреобразование управляемых строк (С#) в LPCOLESTR (С++) - c++Can I buy a context menu control for Silverlight? - silverlight-4.0Why is this code coming out prematurely? - cWhat is the safest way to extractfrom an HTML file using xpath? - html Call JSF ManageBean after PageLoad with f: event postAddToView - java How to show "No Results" screen in UISearchDisplayController? - objective-c GDB and shared object libraries with SIGILL - linux created a PDF file that displays strange characters - pdf-generation Disable scripts in WebBrowser Control - browser All Articles