Multiple classes in a file, the public class is consistent with the Main method

Source: Internet
Author: User

 PackageAbstractclassandinterface; Public classAbstractclasstest { Public Static voidMain (string[] args) {AbstractClass1 AbstractClass=NewAbstractClass1 () {@Overrideprotected voidSetprotectedmethod () {System.out.println ("Calling Method: Setprotectedmethod"); } @Override Public voidSetpublicmethod () {//TODO auto-generated Method Stub} @OverridevoidSetnomethod () {//TODO auto-generated Method Stub                            }        };        Abstractclass.setprotectedmethod (); System.out.println ("Successful Execution"); }} Abstract classabstractclass1{PrivateString a= "Private";  PublicString b= "Public"; protectedString c= "protected"; String D= "NULL"; FinalString e= "Final"; StaticString f= "Static"; //method problems for abstract classes//abstract methods cannot be implemented     Public Abstract voidSetpublicmethod (); //If you are private, you cannot inherit from the quilt class and the subclass cannot implement the method//private abstract void Setprivatemethod (); //protected can be modified    protected Abstract voidSetprotectedmethod (); //Public By default    Abstract voidSetnomethod (); //You can also use a non-abstract method     Public voidSetnotabstractmethod () {}}

More than one class in a file, the public class is consistent with the Main 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.