Two polygon questions for method rewriting in Java

Source: Internet
Author: User

1: What is the difference between a method override and a method overload? Can the method overload change the return value type?

Method overrides:
In a subclass, a behavior that is identical to the method declared in the parent class appears. (includes method name, parameter list, and return value type)

Method overloads:
In the same class, the method names that appear are the same, and the argument lists are different, regardless of the return value type.

The method overload can change the return value type because it is independent of the return value type.

Override: Method Overrides
Overload: Method Overloading

What does the 2:this keyword and super keyword stand for? and their respective use scenarios and roles.

This: Represents an object reference for the current class.
Super: Represents the identity of the parent class storage space. (It can be understood as a reference to the parent class, through which the members of the parent class can be accessed.) )

Application Scenarios:
Member variables:
this. Member variable
Super. Member variables
Construction Method:
This (...)
Super (...)
Member Methods:
This. Member method
Super. Member Methods

Two polygon questions for method rewriting in Java

Related Article

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.