Java overload, overwrite, this, super, abstract class, interface

Source: Internet
Author: User

First, heavy and overwrite

1) Overloading: Method name is the same, parameter type and number are different, typical is the overloading of the construction method

Overwrite: Method name, Parameter type, return value type all the same, typical is the implementation of the interface;

2) overload is not required for permission, overwriting requires that the method of overwriting should not have more strict permissions;

3) overloads occur in another class, and overrides occur in the inheriting class.

Second, this and super

1) This accesses the properties (methods) in this class, and if this attribute (method) is not present in this class, the search continues from the parent class; super queries the attributes (methods) in the parent class;

2) Call this type of construction, must be placed in the first row of the construction method, call the parent class construction, must be placed in the first row of the child class construction method.

3) This represents the current object, and super does not have this concept.

Third, abstract classes and interfaces

1) A class containing an abstract method must be an abstract class; abstract methods need to be declared without implementation; Abstract classes must be inherited.

If the subclass is not an abstract class, it must overwrite all abstract methods of the abstract class;

2) The interface consists of a global variable and a public abstract method.

Java overload, overwrite, this, super, abstract class, interface

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.