5th abstracts and 5th

Source: Internet
Author: User
Tags define abstract

5th abstracts and 5th

IAbstract class

Describe a thing. Because there is not enough information, this thing is called an abstract thing. Abstract is an abstract keyword. The declared class is called an abstract class, and the declared method is called an abstract method.

Abstract attributesThe Declaration does not provide the Implementation of the attribute accessors. It only declares the attributes supported by the class, and the implementation of the accessors is left to the derived class.

Abstract MethodThe Declaration does not provide the Implementation of The method. It must be an empty method and leave the method implementation to the derived class. The derived class must overload the abstract methods of the abstract base class.

Abstract classIt is used as a base class and cannot be directly instantiated, that is, it cannot be used to create objects with abstract classes. Abstract classes are used to provide public definitions of the base classes that can be shared by multiple Derived classes. Abstract class features:

IISeveral questions about abstract classes

1.Is there any constructor in the abstract class?

Yes.Although the constructor of an abstract class cannot instantiate an abstract class object, it cannot create an object, but the abstract class has a subclass. The constructor of an abstract class can be used to instantiate a subclass object.

2.Must an abstract class be a parent class?

Yes.The subclass must overwrite the abstract method before instantiation.

3.Can abstract classes not define abstract methods?

Yes.

4.Abstract keywords abstractAnd which keywords cannot coexist?

Sealed, Private, static.First, the abstract class cannot be sealed or static. The second reason is that virtual and abstract members cannot be private.

3.Differences between abstract classes and interfaces

Note: For details about interfaces, refer to "6th interfaces"

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.