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 judged by the actual object, not by the pointer type (the invocation of the normal function is based on the current pointer type). A pure virtual function is a function that is defined only in the parent function and not implemented, and cannot be used to declare an object or to be called an abstract class. Implementations of pure virtual functions can also be defined outside the class declaration. Abstract class in C + + refers to a class that has at least one pure virtual function, and if a class consists entirely of pure virtual functions and does not include any implementation, it is called pure virtual class.
The normal function in Java comes with the function of virtual function, which is judged by the type of the object pointed to by the pointer. There is no virtual keyword in Java, Java Tube virtual function is called abstract functions, the abstract class is named abstract class, without the concept of pure, but invented a kind of called interface interface to replace the pure virtual class. The difference between interface and abstract class is similar to the difference between a generic abstract class and a pure virtual class in C + +.
Abstract classes can only be used as base classes, cannot be defined objects, the implementation of their pure virtual functions in the derived class, if the derived class also does not give the implementation, then the derived class is an abstract class, only the pure virtual function implementation of the derived class to establish the object. This shows that abstract class is the rhythm of solitary birth, ah, never object.
Other aspects of the comparison are shown in this blog C + + virtual function vs. Java Abstract function comparison interface and abstract class comparison.
C + + virtual function virtual, pure virtual function abstract and Java abstraction function, interface interface and abstract class comparison