Simple solution of abstract class and interface

Source: Internet
Author: User

Abstract classkeyword abstractAbstract classes are often used to characterize the abstract concepts of analysis and design of problem areas, and are abstractions of a series of concrete concepts that look different, but are essentially the same. Classes that are typically decorated in a programming statement are abstract classes. In Java, a class that contains abstract methods is called an abstract class and cannot produce an object. An abstract class is incomplete and can only be used as an inheritance. In an object-oriented approach, abstract classes are primarily used for type concealment and for roles that act as global variables.The above Baidu Encyclopedia of abstract class interpretation.

Understand the following abstract methods before learning abstract classes:

An abstract method is a method that is declared but not implemented, that is, a method that does not have any function code.

A typical abstract method is declared as follows

public abstract void Method ();

you can see that the abstract method does not even have the curly braces of the normal method, but ends with a semicolon. It can be seen from this that abstract methods are inherently used to inherit the main purpose of which is to declare methods, subclasses of non-abstract classes

Provide specific implementation code.

Note:
    1. Abstract methods can only be public protected if the private subclass cannot implement the parent class method, the abstract method has no meaning.
    2. Abstract classes cannot be marked as final because abstract must be inherited.
    3. The first non-abstract subclass of an abstract class must implement all its abstract methods.
    4. Abstract classes can never be instantiated.

Interface writing .....

Simple solution of abstract class and interface

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.