Java class inheritance, the procedure called by the parent class subclass method

Source: Internet
Author: User

1, the Mytank class inherits the tank, then the public part of Mytank inside is the common member and the method in Mytank can call and assignment, and do not have the new member variable in Mytank and the public member name in the tank, this will occur the call disorder, such as:

Tank Tank = new Mytank ();

int c = TANK.A;

If public a= 3 is in the tank class, and the new definition public A = 2 in the Mytank subclass, then the call in the above code will make C = 3, and a in the parent class.

Java class inheritance, the procedure called by the parent class subclass method

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.