Abstract classThe abstract modifier can be used with classes, methods, properties, indexers, and events.1. Abstract classes cannot be instantiated.2. Abstract classes can contain abstract methods and abstract accessors.3.
Basic Java Learning--abstract classes and abstract functions
Abstract class
An abstract class cannot make an object, but a variable can be defined, and the object assigned to the variable must be a non-abstract subclass of it;
Abstract classes and abstract methods(Abstract classes must be inherited, abstract methods must be heavy)Abstract class: A class that contains an abstract method.Abstract methods: Methods that are declared but not implemented, the
Label: style uses the SP code BS to apply the nbsp Object C
Object-oriented applications (I)
Suffering from customers' changing demands"
According to customer requirements, printers of different brands have the functions of starting, shutting down, and printing, so the code will not be written here
1. Syntax features of Abstract Functions
What is an abstract function?
Only functions are defined. f
java– virtual functions, abstract functions, abstract classes, interfaces
1. Java virtual functions
The existence of virtual functions is for polymorphism.
C + + Ordinary member function plus virtual keyword becomes virtual function
In Java, there is no concept of virtual function, its ordinary function is equivalent to C + + virtual functions, dynamic binding is the default behavior of Java. If you do no
Static, abstract class, interface, class library, abstract class library
1. Common MemberCommon members belong to objects.Call with object
2. Static membersStatic members belong to the classCalled by Class Name
Stactic static keywords
Static methods cannot contain common members.The common method can contain static members.
Abstract class:
1. Keywords: abstract2
// Abstract method: it only contains the method definition, but does not have a specific implementation method. It must be implemented by its subclass or subclass.
// Static methods cannot be marked as override, virtual, or abstract. That is, static methods must be specific.
/Abstract class: a class that contains one or more
Abstract classes cannot be directly instantiated:
Using system; abstract class myclass {} class program {static void main () {/* abstract class cannot be directly instantiated. the following error occurs */myclass OBJ = new myclass (); console. readkey ();}}
However, abstract classes can be instantiated b
/*+ ------------------------------------------------------------------------------- +| = Read this article for Haohappy | = Notes in the Classes and Objects chapter| = Translation-oriented + personal experiences| = Do not repost it to avoid unnecessary troubles. Thank you.| = Thank you for your criticism and hope to make progress together with all PHP fans!+ ------------------------------------------------------------------------------- +*/Section 10-abstrac
1. Java virtual functionsThe existence of virtual functions is for polymorphism.C + + the normal member function plus Virtual The keyword becomes a virtual functionjava c++ java java final keyword becomes non-virtual function PS: actually C + + and the Java The point of view in virtual function is similar. 2. Java abstract function ( pure virtual function ) The existence of abstract functions, o
1.final: The final, immutable------are less likely to be used alone1) modifier variable: variable cannot be changed2) Modification Method: Method cannot be overridden3) Modifier class: class cannot be inherited2.static Final: Constant, high application rate1) must declare simultaneous initialization2) accessed through the class name and cannot be changed.3) Recommended: Constant name All letters are capitalized, multiple words separated by _4) compiler directly replaces constants with specific v
The examples in this article describe abstract classes and abstract methods in PHP. Share to everyone for your reference, specific as follows:
One, abstract key words: abstract
Abstraction is not an exact description, but there is a certain concept or name, in PHP to declare an a
Java basics -- abstract classes and Abstract Functions, java --
Abstract class
Abstract classes cannot create objects, but can define variables. The objects assigned to this variable must be non-Abstract subclass objects;
Abstrac
Abstract classes realize polymorphism and abstract class Polymorphism
I. What is polymorphism?
Multiple forms: different objects make different actions for the same operation.
Ii. Notes for abstract classes
1. abstract classes are modified using abstract
2.
1. Java Virtual functionsThe existence of virtual functions is for polymorphism.The ordinary member function plus the virtual keyword in C + + becomes a virtual functionIn Java, there is no virtual function concept, its normal function is equivalent to C + + virtual function, dynamic binding is the default behavior of Java. If you do not want a function in Java to have a virtual function attribute, you can add the final keyword to a non-virtual functionPS: In fact, C + + and Java in the virtual
Implementation of abstract classes and abstract methodsAn abstract class is a special kind of basic class that is not associated with a specific thing. The definition of an abstract class uses the keyword abstract.In the hierarchy of classes, there is no such thing as "graphics", so it is possible to define "graph" as
Abstract ModifierAbstract: A class can be modified to indicate an abstract class. Note: the unique difference between an abstract class and a specific class: A class cannot create objects, but a specific class can create objects.1. The specific classes have constructor methods, and the abstract classes also have constr
Differences between abstract classes and interfaces
Abstract classes can contain non-abstract methods, and interfaces can only contain abstract methods.
Abstract classes cannot contain braces when declaring abstract methods, b
In PHP, the interface abstract class, final, static a few of the fairly simple we used, especially the large Web site architecture will be useful, today we look at an abstract class in PHP, final, static example.
1. Interface(1) The use of the interface is through the keyword implements(2) Interfaces cannot define member variables (including class static variables) and can define constants(3) Subclasses mu
1. There is no static abstract method in Java abstract class.Abstract classes cannot be instantiated, that is, memory cannot be allocated, and static-decorated methods do not allocate memory until the class is instantiated, so the contradiction arises: the abstract class cannot be allocated memory, and the static method must be allocated memory. Therefore,
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.