Abstract classes and Interfaces

Source: Internet
Author: User

I. Abstract class
1. Abstract classes are not understood, abstract
2. Characteristics of abstract Fatigue:
1). Abstract class and abstract methods must be decorated using the abstract keyword
2). Abstract classes do not necessarily have abstract methods, classes with abstract methods must be abstract classes or interfaces
3). Abstract classes can not be instantiated, in a polymorphic way, there is a specific subclass instantiation, in fact, this is a polymorphic, abstract polymorphism
4). Subclasses of abstract classes are either abstract classes or override all abstract methods
3. Member characteristics of abstract classes
1) member variable: can be either a variable or a constant, abstract is not allowed to modify the member variable
2). There is a constructor method for subclasses to access the initialization of the parent class
3). Member method: can be either non-abstract or non-abstract
Two. Interface
1. Interface: From the narrow sense refers to the Java interface, from a broad sense of the external provision of rules is the interface
2. Features of the interface:
A. The interface is represented by the keyword interface;
B. Class implementation interfaces are represented by implement;
C. Interfaces cannot be instantiated
D. The subclass of an interface can be an abstract class, or a concrete class, to override all abstract methods in an interface
3. Features of the interface members:
1). Member variable: can only be constant, and is static and public
2). No construction method in the interface
3). Member methods can only be abstract methods
4). Classes and interfaces are implementation relationships, interfaces and interfaces are inheritance relationships

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.