The problem that this paper solves
What is abstract class
Application Scenarios for abstract classes
Can interfaces be implemented in a method?
The difference between an interface and an abstract class
1 What is abstract
Abstract class and interface are two mechanisms supported for the definition of abstract classes in Java. It is precisely because of the existence of these two mechanisms that give Java powerful object-oriented capabilities. Abstract class and
Document directory
Code for testing
Original post address: http://www.codeproject.com/KB/cs/abstractsvsinterfaces.aspx
Original Author:Rahman Mahmoodi
Translation: 54sunIntroduction | description
I will discuss abstract class and interface
1. Abstract class 1.1 Abstract class conceptsWhen some methods of the parent class are not deterministic, you can use the abstract keyword to decorate the method [abstract method] and use abstract to decorate the class [abstract class]. //the
Abstract class vs Interface
Differences
Abstract class methods can have method bodies, while interface methods cannot have method bodies.
Methods in abstract classes. If abstract modifier is not added, the method body must be defined.
Class
In an object-oriented (OOP) language, a class can have one or more subclasses, and each class has at least one interface that the public method accesses as external code. and abstract methods are introduced to facilitate inheritance, now look at how
Because both C + + and Java are object-oriented programming languages, their polymorphism is achieved by virtual functions and abstract functions, respectively.The virtual function of C + + can be overridden in subclasses, and the invocation is
1. There is at least one method that is modified by the abstract, while the class that modifies the class name is an abstraction class, the abstract method must be covered by the quilt class, the abstract class must be inherited, and the abstract
Differences
Abstract class methods can have method bodies, while interface methods cannot have method bodies.
Methods in abstract classes. If abstract modifier is not added, the method body must be defined.
Class can implement multiple
Abstract class vs. interface comparisonAbstract classes, like interfaces, cannot be instantiated and may contain methods that do not require implementation or have been implemented.Abstract classes can define a number of fields that are not static
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.