新版面试题整理
所属分类:Java编程
开发工具:Java
文件大小:134KB
下载次数:1
上传日期:2017-07-04 08:50:31
上 传 者:阿萨德a
说明: 3.重写和重载的特点和区别?
a)重载
简单说,就是函数或者方法有同样的名称,但是参数列表不相同的情形,这样的同名不同参数的函数或者方法之间,互相称之为重载函数或者方法。
b)重写
重写指的是在Java的子类与父类中有两个名称、参数列表和返回值类型都相同的方法的情况。由于他们具有相同的方法签名,所以子类中的新方法将覆盖父类中原有的方法。
重写是父类与子类之间的多态性,对父类的函数进行重新定义。
c)区别
(features and differences in rewriting and overloading?
A) overloading
Simply put, that is, the function or method has the same name, but the parameter list is not the same, so that functions or methods with different parameters of the same name are called overloaded functions or methods among themselves.
B) Rewrite
Rewriting refers to the way in which the subclass of Java and the parent class have two names, parameter lists, and the same type of return value. Since they have the same method signature, the new method in the subclass overrides the original method in the parent class.
Rewriting is the polymorphism between the parent class and subclass, redefining the functions of the parent class.
C) difference)
文件列表:[举报垃圾]
鏂扮増闈㈣瘯棰樻暣鐞?
近期下载者:
相关文件:
收藏者: