1. overloading vs overriding
Definition:
overloading: same method name, different number of argument or argument type. no permission limitation
overriding: same method name, number of argument and argument type. private<default<public
Usage:
overloading; within a class
overriding: in a class inheritance
2. this vs super
.member or .method
this: looking in current class first, then looking in parent class if not found in current class
super: looking in the parent class
this() or supper() used in the constructor
this(): call constructor of current class, put at the first line
supper(): call constructor of parent class, put at the first line
refer to a object ( passed in as argument)
this: means current object
supper: no such concept
没有评论:
发表评论