In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "what are the characteristics of java reloading and rewriting". In daily operation, I believe that many people have doubts about the characteristics of java reloading and rewriting. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "what are the characteristics of java reloading and rewriting?" Next, please follow the editor to study!
Characteristics of rewriting
1. The parameter list must be exactly the same as that of the overridden method
two。 The return type must be exactly the same as the return type of the overridden method
3. The access level must not be more restrictive than the overridden method
4. The access level can be less restrictive than the overridden method
5. Overridden methods must not throw new check exceptions or check exceptions more widely than those declared by overridden methods.
6. Overridden methods can throw fewer or more limited exceptions (that is, overridden methods declare exceptions, but overridden methods can declare nothing)
7. Methods marked as final cannot be overridden
8. If you cannot inherit a method, you cannot override it.
Characteristics of overloading
1. The overloaded method must change the parameter list
two。 Overloaded methods can change the return type
3. Overloaded methods can change access modifiers
4. Overloaded methods can declare new or broader check exceptions
5. Methods can be overloaded in the same class or in a subclass.
The general interview is to ask, what is the difference between overloading and rewriting? at this time, the standard answer is that overloading is a function or method with the same name, but the parameter list is different, and the methods with different parameters with the same name are called overloading each other. Overriding means that the subclass of the java and the parent class have the same name, parameter list and method, and the subclass will overwrite the original method of the parent class. If you want a detailed answer, you can answer questions such as access restrictions, which will add points.
At this point, the study on "what are the characteristics of java reloading and rewriting" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.