Java11 month 9th the hands of the brain

Source: Internet
Author: User

Java hands-on brain

Write your own code to test the following features (hands-on brain):

In subclasses, to invoke methods overridden in a parent class, you can use the Super keyword.

Program Source code:

Package Yanzhengjicheng;

Class add{

public int Jiafa (int a,int b) {

int s;

S=a+b;

return s;

}

}

Class Add1 extends add{

public int Jiafa (int a,int b) {System.out.println ("Call the parent class" +super.jiafa (3,4));

int s;

S=a+b;

return s;

}

}

public class Testinter {

public static void Main (String args[]) {

Add1 C = new Add1 ();

System.out.println ("Call subclass" +c.jiafa (3,4));

}

}

(2) Program operation result diagram:

Java11 month 9th the hands of the brain

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.