Dark Horse programmer-java Basics-Abstract classes and interfaces

Source: Internet
Author: User

1, the abstract class can have a construction method, mainly when the subclass is instantiated, initialization. 2, there can be no abstract method in an abstract classThe point is not to let outsiders create objects.  

3, the coexistence of abstract classes and keywords

    Private Abstratc method ();   To rewrite, but does not support overriding final abstract method (); Final is to let subclasses do not rewrite static abstract method (); Method belongs to a class and must be implemented 1, the abstract class can implement the interface in which the methods can be implemented, or can not be implemented. 2. Member Characteristics member variables (there are few interface variables in the interface) are Public static Final member Methods all for public abstract There are construction methods method Body is throw new Error ("Unresolved compilation problems: \n\tinterfaces cannot has constructors\n\tsyntax error on t Oken \ "}\", delete   Abstract class is the Is-a relationship interface is the like-a relationship after the class inheritance structure is an abstract class implementation of multiple interfaces, and then multiple subclasses to inherit the abstract class.    Two interfaces have the same method of the same signature, when the specific subclass in the implementation of both methods, can only use one to replace. If the methods in the two interface represent different behaviors, you should make a difference on the method name if you are representing the same behavior, then you should proceed to extract it upward.

Dark Horse programmer-java Basics-Abstract classes and interfaces

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.