Ordinary Class abstract class Interface

Source: Internet
Author: User

First, you must understand what is an abstract class:
I. concept:
In the concept of object-oriented, we know that all objects are depicted through classes, but this is not the case.
Not all classes are used to depict objects. If a class does not contain enough information to depict a specific object, such classes are abstract classes.
For example, if we develop a graphic editing software, we will find some specific concepts such as circles and triangles in the problematic domain.
They are different, but they all belong to the concept of shape. The concept of shape does not exist in the field of problems. It is an abstract concept.
Abstract concepts cannot be instantiated because they do not have specific concepts in the problem field.
Ii. Syntax:
Abstract classes can have abstract methods or common methods. abstract methods can only be declared and cannot be instantiated (that is, they cannot have method bodies ),
It must be instantiated by a common class that inherits this abstract class.

Secondly, an interface is a special abstract class.
The difference is that the methods in the interface must be abstract methods, rather than common methods.

Another example is the image comparison:
Ordinary Class ------ we ordinary people;
Abstract class ------ Sister Furong (everyone has the ability to break the idea and keep the old tradition, but only Sister Furong has the guts );
Interface ------ spider and Superman (implementing interfaces is equivalent to having some special functions ).

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.