当前位置:网站首页>Which methods are not allowed to be overridden?

Which methods are not allowed to be overridden?

2022-06-22 05:08:00 Xeon-Shao

1. subject
 Methods that are not allowed to be overridden include ?
A. Class quilt final modification 
B. Method is final modification 
C. Method is static modification 
D. Method is protected modification 
2. analysis

1.A Options . A class is final modification , Then this class cannot be inherited , Therefore, there is no chance that the methods of this class will be overridden .
It should also be clear here rewrite and heavy load The difference between , rewrite Occurs between subclasses and superclasses , Subclasses override methods of the parent class , Method name 、 Return value 、 The parameters are the same ; heavy load Occurs in the same class , You can simply understand different implementations of the same method , Same method name , Different parameters , The return value can be the same or different ( Generally the same ).
Sample code :

public final class 
原网站

版权声明
本文为[Xeon-Shao]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206220501573474.html